IntervalTrigger

This commit is contained in:
qiaofeng1227 2023-06-19 13:50:40 +08:00
parent 9019dfb9bb
commit f27f79ffb7
2 changed files with 4 additions and 5 deletions

View File

@ -10,7 +10,7 @@ COPY static ./static
COPY requirements.txt main.py ./ COPY requirements.txt main.py ./
RUN apt update RUN apt update
# Install supervisord # Install supervisords
RUN apt install -y supervisor RUN apt install -y supervisor
COPY config/supervisord.conf /etc/supervisor/conf.d/supervisord.conf COPY config/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
COPY config/cmd.sh /cmd.sh COPY config/cmd.sh /cmd.sh

View File

@ -37,8 +37,7 @@ def auto_update():
shell_execute.execute_command_output_all("wget https://websoft9.github.io/StackHub/install/update_appstore.sh && bash update_appstore.sh 1>/dev/null 2>&1") shell_execute.execute_command_output_all("wget https://websoft9.github.io/StackHub/install/update_appstore.sh && bash update_appstore.sh 1>/dev/null 2>&1")
scheduler = BackgroundScheduler() scheduler = BackgroundScheduler()
#scheduler.add_job(auto_update, CronTrigger(hour='1'), id='auto_update_job') scheduler.add_job(auto_update, IntervalTrigger(minutes=1))
scheduler.add_job(auto_update, CronTrigger.from_crontab('15 * * * * *'))
# 获取github文件内容 # 获取github文件内容
def get_github_content(repo, path): def get_github_content(repo, path):
@ -54,13 +53,13 @@ def AppAutoUpdate(auto_update):
myLogger.info_logger(scheduler.state) myLogger.info_logger(scheduler.state)
myLogger.info_logger(scheduler.get_jobs()) myLogger.info_logger(scheduler.get_jobs())
if auto_update: if auto_update:
if scheduler.state == 1: if scheduler.state == 1 or scheduler.state == "1":
raise CommandException(const.ERROR_CLIENT_PARAM_REPEAT,"auto_update already in running state", "auto_update already in running state") raise CommandException(const.ERROR_CLIENT_PARAM_REPEAT,"auto_update already in running state", "auto_update already in running state")
else: else:
scheduler.start() scheduler.start()
return "软件商店自动更新已经开启" return "软件商店自动更新已经开启"
else: else:
if scheduler.state == 0: if scheduler.state == 0 or scheduler.state == "0":
raise CommandException(const.ERROR_CLIENT_PARAM_REPEAT,"auto_update already in closed state", "auto_update already in closed state") raise CommandException(const.ERROR_CLIENT_PARAM_REPEAT,"auto_update already in closed state", "auto_update already in closed state")
else: else:
scheduler.shutdown() scheduler.shutdown()