auto
This commit is contained in:
parent
1ce74e0d67
commit
4b94da339b
2 changed files with 9 additions and 8 deletions
|
@ -10,7 +10,7 @@ COPY static ./static
|
|||
COPY requirements.txt main.py ./
|
||||
RUN apt update
|
||||
|
||||
# Install supervisords
|
||||
# Install supervisord
|
||||
RUN apt install -y supervisor
|
||||
COPY config/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
|
||||
COPY config/cmd.sh /cmd.sh
|
||||
|
|
|
@ -25,7 +25,7 @@ from apscheduler.schedulers.background import BackgroundScheduler
|
|||
from apscheduler.triggers.date import DateTrigger
|
||||
from apscheduler.triggers.cron import CronTrigger
|
||||
from apscheduler.triggers.interval import IntervalTrigger
|
||||
|
||||
from apscheduler.events import EVENT_SCHEDULER_PAUSED, EVENT_SCHEDULER_RESUMED,EVENT_SCHEDULER_STARTED,EVENT_SCHEDULER_SHUTDOWN
|
||||
|
||||
# 指定 Redis 容器的主机名和端口
|
||||
redis_conn = Redis(host='websoft9-redis', port=6379)
|
||||
|
@ -41,6 +41,9 @@ def test():
|
|||
shell_execute.execute_command_output_all("echo 1111 >> /tmp/test1")
|
||||
|
||||
scheduler = BackgroundScheduler()
|
||||
scheduler.add_job(auto_update, 'cron', second=1)
|
||||
scheduler.add_job(test, 'cron', second=1)
|
||||
scheduler.start()
|
||||
|
||||
# 获取github文件内容
|
||||
def get_github_content(repo, path):
|
||||
|
@ -56,18 +59,16 @@ def AppAutoUpdate(auto_update):
|
|||
myLogger.info_logger(scheduler.state)
|
||||
myLogger.info_logger(scheduler.get_jobs())
|
||||
if auto_update:
|
||||
if scheduler.state == 1 or scheduler.state == "1":
|
||||
if scheduler.state == EVENT_SCHEDULER_RESUMED or scheduler.state == EVENT_SCHEDULER_STARTED:
|
||||
raise CommandException(const.ERROR_CLIENT_PARAM_REPEAT,"auto_update already in running state", "auto_update already in running state")
|
||||
else:
|
||||
scheduler.add_job(auto_update, 'cron', second=1)
|
||||
scheduler.add_job(test, 'cron', second=1)
|
||||
scheduler.start()
|
||||
scheduler.resume()
|
||||
return "软件商店自动更新已经开启"
|
||||
else:
|
||||
if scheduler.state == 0 or scheduler.state == "0":
|
||||
if scheduler.state == EVENT_SCHEDULER_PAUSED:
|
||||
raise CommandException(const.ERROR_CLIENT_PARAM_REPEAT,"auto_update already in closed state", "auto_update already in closed state")
|
||||
else:
|
||||
scheduler.shutdown()
|
||||
scheduler.pause()
|
||||
return "软件商店自动更新已经关闭"
|
||||
|
||||
# 更新软件商店
|
||||
|
|
Loading…
Add table
Reference in a new issue