mirror of
https://gitee.com/sui-feng-cb/AzurLaneAutoScript1
synced 2026-04-20 12:59:47 +08:00
Opt: Change directories of reload listening
This commit is contained in:
4
.gitignore
vendored
4
.gitignore
vendored
@@ -14,8 +14,8 @@ dev_tools/debug_tools
|
||||
/campaign/test/
|
||||
/toolkit
|
||||
*.lock
|
||||
reloadflag
|
||||
reloadalas
|
||||
config/reloadflag
|
||||
config/reloadalas
|
||||
test.py
|
||||
|
||||
# Created by .ignore support plugin (hsz.mobi)
|
||||
|
||||
4
gui.py
4
gui.py
@@ -97,9 +97,9 @@ if __name__ == '__main__':
|
||||
logger.attr('Port', port)
|
||||
|
||||
try:
|
||||
os.remove('./reloadflag')
|
||||
os.remove('./config/reloadflag')
|
||||
except:
|
||||
pass
|
||||
|
||||
uvicorn.run('module.webui.app:app', host=host, port=port, factory=True,
|
||||
uvicorn.run('module.webui.app:app', host=host, port=port, factory=True, reload_dirs=[os.path.join(os.getcwd(), './config/')],
|
||||
reload=True, reload_includes=['reloadflag'], reload_excludes=['*.py'])
|
||||
|
||||
@@ -62,7 +62,7 @@ class AlasManager:
|
||||
return 1
|
||||
elif len(self.log) == 0 or self.log[-1] == "Scheduler stopped.\n":
|
||||
return 2
|
||||
elif self.log[-2].endswith('Update event detected'):
|
||||
elif self.log[-2].endswith('Update event detected\n'):
|
||||
return 4
|
||||
else:
|
||||
return 3
|
||||
@@ -141,7 +141,7 @@ class AlasManager:
|
||||
if not instances:
|
||||
instances = []
|
||||
try:
|
||||
with open('./reloadalas', mode='r') as f:
|
||||
with open('./config/reloadalas', mode='r') as f:
|
||||
for line in f.readlines():
|
||||
line = line.strip()
|
||||
instances.append(AlasManager.get_alas(line))
|
||||
@@ -153,7 +153,7 @@ class AlasManager:
|
||||
alas.start(func='Alas', ev=ev)
|
||||
|
||||
try:
|
||||
os.remove('./reloadalas')
|
||||
os.remove('./config/reloadalas')
|
||||
except:
|
||||
pass
|
||||
logger.info("Start alas complete")
|
||||
|
||||
@@ -234,7 +234,7 @@ class Updater(Config, Installer):
|
||||
|
||||
if updater.update():
|
||||
self.state = 'reload'
|
||||
with open('./reloadalas', mode='w') as f:
|
||||
with open('./config/reloadalas', mode='w') as f:
|
||||
f.writelines(names)
|
||||
from module.webui.app import clearup
|
||||
self._trigger_reload(2)
|
||||
@@ -249,7 +249,7 @@ class Updater(Config, Installer):
|
||||
@staticmethod
|
||||
def _trigger_reload(delay=2):
|
||||
def trigger():
|
||||
with open('./reloadflag', mode='w'):
|
||||
with open('./config/reloadflag', mode='w'):
|
||||
# app ended here and uvicorn will restart whole app
|
||||
pass
|
||||
timer = threading.Timer(delay, trigger)
|
||||
|
||||
Reference in New Issue
Block a user