Commit 02cae322 authored by Mikaël Salson's avatar Mikaël Salson Committed by marc duez
Browse files

server/admin: Restart workers

Fix #3554, inspired by vdj#727
parent 6c9a9b9f
......@@ -775,9 +775,9 @@ Disks failures or other events could have triggered a read-only partition.
For some reasons, that are not clear yet, it may happen that workers are not
assigned any additional jobs even if they don't have any ongoing jobs.
In such a (rare) case, it may be useful to restart web2py schedulers
with `service web2py-scheduler restart` or `initctl restart web2py-scheduler`
depending on your installation.
In such a (rare) case, it may be useful to restart the workers by clicking on
the *reset workers* link in the Vidjil administration interface. Restarting
workers won't be performed if jobs are currently running or assigned.
## Debugging Web2py workers
......
......@@ -2,7 +2,7 @@
import gluon.contrib.simplejson, re
import os.path, subprocess
import vidjil_utils
from gluon.scheduler import RUNNING, QUEUED, ASSIGNED
MAX_LOG_LINES = 500
ACCESS_DENIED = "access denied"
......@@ -194,4 +194,14 @@ def repair():
log.admin(res)
return gluon.contrib.simplejson.dumps(res, separators=(',',':'))
def reset_workers():
if auth.is_admin():
running_jobs = db((db.scheduler_task.status == RUNNING) | (db.scheduler_task.status == ASSIGNED)).count()
if running_jobs == 0:
db(db.scheduler_worker.id > 0).delete()
db.commit()
res = {"success" : "true", "message" : "Workers have been reset "}
else:
res = {"success" : "false", "message" : "Jobs are currently running or assigned. I don't want to restart workers"}
log.admin(res)
return gluon.contrib.simplejson.dumps(res, separators=(',',':'))
......@@ -10,6 +10,7 @@
<a class="button" onclick="db.call('admin/repair_missing_files');">fix missing files</a>
<a class="button" onclick="db.call('admin/repair');">repair db</a>
<a class="button" onclick="db.call('admin/make_backup');">make backup</a>
<a class="button" title="When jobs remain QUEUED, restarting workers may help" onclick="db.call('admin/reset_workers');">reset workers</a>
</br>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment