chore: 优化启动脚本

This commit is contained in:
Folltoshe 2024-11-17 20:57:11 +08:00
parent 92a69f048d
commit 5442e3340b
4 changed files with 36 additions and 38 deletions

View File

@ -3,11 +3,11 @@
"version": "2.0.0.beta-12",
"description": "一个适配 LX Music 的 API 后端实现",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"dev": "poetry run python poetry_run.py development",
"prod": "poetry run python poetry_run.py production",
"development": "poetry run python poetry_run.py development",
"production": "poetry run python poetry_run.py production",
"install": "poetry install"
"dev": "python run.py development",
"prod": "python run.py production",
"install": "pip install -r requirements.txt",
"poetry:install": "poetry install",
"poetry:development": "poetry run python run.py development",
"poetry:production": "poetry run python run.py production"
}
}

View File

@ -1,23 +0,0 @@
import os
import argparse
import subprocess
def main_production():
os.environ['CURRENT_ENV'] = 'production'
subprocess.run(["python", "main.py"])
def main_development():
os.environ['CURRENT_ENV'] = 'development'
subprocess.run(["python", "main.py"])
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Script to set environment variables and run different environments.")
parser.add_argument("environment", choices=["production", "development"], help="Specify the environment to run.")
args = parser.parse_args()
try:
if args.environment == "production":
main_production()
elif args.environment == "development":
main_development()
except KeyboardInterrupt:
pass

21
run.py Normal file
View File

@ -0,0 +1,21 @@
import os
import argparse
import subprocess
if __name__ == "__main__":
parser = argparse.ArgumentParser(escription="Script to set environment variables and run different environments.")
parser.add_argument(
"environment",
choices=["production", "development"],
nargs="?",
default="production",
help="Specify the environment to run.",
)
args = parser.parse_args()
try:
if args.environment:
os.environ["CURRENT_ENV"] = args.environment
subprocess.run(["python", "main.py"])
except KeyboardInterrupt:
pass

View File

@ -9,16 +9,16 @@ except Exception:
description = "Description not available"
setup(
name='lx_music_api_server_setup',
name="lx_music_api_server_setup",
version=version,
scripts=['poetry_run.py'],
author='helloplhm-qwq',
author_email='helloplhm-qwq@outlook.com',
scripts=["run.py"],
author="helloplhm-qwq",
author_email="helloplhm-qwq@outlook.com",
description=description,
url='https://github.com/helloplhm-qwq/lx-music-api-server',
url="https://github.com/helloplhm-qwq/lx-music-api-server",
classifiers=[
'Programming Language :: Python :: 3',
'License :: OSI Approved :: MIT License',
'Operating System :: OS Independent',
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
],
)