mirror of
https://github.com/MeoProject/lx-music-api-server.git
synced 2025-05-23 19:17:41 +08:00
chore: 优化启动脚本
This commit is contained in:
parent
92a69f048d
commit
5442e3340b
14
package.json
14
package.json
@ -3,11 +3,11 @@
|
|||||||
"version": "2.0.0.beta-12",
|
"version": "2.0.0.beta-12",
|
||||||
"description": "一个适配 LX Music 的 API 后端实现",
|
"description": "一个适配 LX Music 的 API 后端实现",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "echo \"Error: no test specified\" && exit 1",
|
"dev": "python run.py development",
|
||||||
"dev": "poetry run python poetry_run.py development",
|
"prod": "python run.py production",
|
||||||
"prod": "poetry run python poetry_run.py production",
|
"install": "pip install -r requirements.txt",
|
||||||
"development": "poetry run python poetry_run.py development",
|
"poetry:install": "poetry install",
|
||||||
"production": "poetry run python poetry_run.py production",
|
"poetry:development": "poetry run python run.py development",
|
||||||
"install": "poetry install"
|
"poetry:production": "poetry run python run.py production"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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
21
run.py
Normal 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
|
16
setup.py
16
setup.py
@ -9,16 +9,16 @@ except Exception:
|
|||||||
description = "Description not available"
|
description = "Description not available"
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name='lx_music_api_server_setup',
|
name="lx_music_api_server_setup",
|
||||||
version=version,
|
version=version,
|
||||||
scripts=['poetry_run.py'],
|
scripts=["run.py"],
|
||||||
author='helloplhm-qwq',
|
author="helloplhm-qwq",
|
||||||
author_email='helloplhm-qwq@outlook.com',
|
author_email="helloplhm-qwq@outlook.com",
|
||||||
description=description,
|
description=description,
|
||||||
url='https://github.com/helloplhm-qwq/lx-music-api-server',
|
url="https://github.com/helloplhm-qwq/lx-music-api-server",
|
||||||
classifiers=[
|
classifiers=[
|
||||||
'Programming Language :: Python :: 3',
|
"Programming Language :: Python :: 3",
|
||||||
'License :: OSI Approved :: MIT License',
|
"License :: OSI Approved :: MIT License",
|
||||||
'Operating System :: OS Independent',
|
"Operating System :: OS Independent",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user