mirror of
https://github.com/YunoHost/yunorunner.git
synced 2024-09-03 20:05:52 +02:00
Restart jobs when the server stop
This commit is contained in:
parent
6b70f46789
commit
0395d4349e
1 changed files with 31 additions and 6 deletions
37
run.py
37
run.py
|
@ -1192,6 +1192,37 @@ def format_frame(f):
|
||||||
return dict([(k, str(getattr(f, k))) for k in keys])
|
return dict([(k, str(getattr(f, k))) for k in keys])
|
||||||
|
|
||||||
|
|
||||||
|
@app.listener("before_server_start")
|
||||||
|
async def listener_before_server_start(*args, **kwargs):
|
||||||
|
task_logger.info("before_server_start")
|
||||||
|
reset_pending_jobs()
|
||||||
|
reset_busy_workers()
|
||||||
|
merge_jobs_on_startup()
|
||||||
|
|
||||||
|
set_random_day_for_monthy_job()
|
||||||
|
|
||||||
|
|
||||||
|
@app.listener("after_server_start")
|
||||||
|
async def listener_after_server_start(*args, **kwargs):
|
||||||
|
task_logger.info("after_server_start")
|
||||||
|
|
||||||
|
|
||||||
|
@app.listener("before_server_stop")
|
||||||
|
async def listener_before_server_stop(*args, **kwargs):
|
||||||
|
task_logger.info("before_server_stop")
|
||||||
|
|
||||||
|
|
||||||
|
@app.listener("after_server_stop")
|
||||||
|
async def listener_after_server_stop(*args, **kwargs):
|
||||||
|
task_logger.info("after_server_stop")
|
||||||
|
for job_id in jobs_in_memory_state:
|
||||||
|
await stop_job(job_id)
|
||||||
|
job = Job.select().where(Job.id == job_id)[0]
|
||||||
|
job.state = "scheduled"
|
||||||
|
job.log = ""
|
||||||
|
job.save()
|
||||||
|
|
||||||
|
|
||||||
def main(config="./config.py"):
|
def main(config="./config.py"):
|
||||||
|
|
||||||
default_config = {
|
default_config = {
|
||||||
|
@ -1213,12 +1244,6 @@ def main(config="./config.py"):
|
||||||
print(f"Error: analyzer script doesn't exist at '{app.config.PATH_TO_ANALYZER}'. Please fix the configuration in {config}")
|
print(f"Error: analyzer script doesn't exist at '{app.config.PATH_TO_ANALYZER}'. Please fix the configuration in {config}")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
reset_pending_jobs()
|
|
||||||
reset_busy_workers()
|
|
||||||
merge_jobs_on_startup()
|
|
||||||
|
|
||||||
set_random_day_for_monthy_job()
|
|
||||||
|
|
||||||
if app.config.MONITOR_APPS_LIST:
|
if app.config.MONITOR_APPS_LIST:
|
||||||
app.add_task(monitor_apps_lists(monitor_git=app.config.MONITOR_GIT,
|
app.add_task(monitor_apps_lists(monitor_git=app.config.MONITOR_GIT,
|
||||||
monitor_only_good_quality_apps=app.config.MONITOR_ONLY_GOOD_QUALITY_APPS))
|
monitor_only_good_quality_apps=app.config.MONITOR_ONLY_GOOD_QUALITY_APPS))
|
||||||
|
|
Loading…
Add table
Reference in a new issue