[Bug fix] Import way to run

- Fix a bug that if you import the main app, especially when using gunicorn, you will miss some necessary initial operations. #216
This commit is contained in:
Lost-MSth
2025-08-06 17:29:05 +08:00
parent 46b3b053cf
commit 4911511ed7
2 changed files with 7 additions and 2 deletions

View File

@@ -170,7 +170,7 @@ def generate_log_file_dict(level: str, filename: str) -> dict:
}
def main():
def pre_main():
log_dict = {
'version': 1,
'root': {
@@ -208,6 +208,8 @@ def main():
input('Press ENTER key to exit.')
sys.exit()
def main():
if Config.LINKPLAY_HOST and Config.SET_LINKPLAY_SERVER_AS_SUB_PROCESS:
from linkplay_server import link_play
process = [Process(target=link_play, args=(
@@ -223,6 +225,9 @@ def main():
tcp_server_run()
# must run for init
pre_main()
if __name__ == '__main__':
set_start_method("spawn")
main()