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
ACCESS_DENIED = "access denied"
......@@ -194,4 +194,14 @@ def repair():
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( > 0).delete()
res = {"success" : "true", "message" : "Workers have been reset "}
res = {"success" : "false", "message" : "Jobs are currently running or assigned. I don't want to restart workers"}
return gluon.contrib.simplejson.dumps(res, separators=(',',':'))
......@@ -10,6 +10,7 @@
<a class="button" onclick="'admin/repair_missing_files');">fix missing files</a>
<a class="button" onclick="'admin/repair');">repair db</a>
<a class="button" onclick="'admin/make_backup');">make backup</a>
<a class="button" title="When jobs remain QUEUED, restarting workers may help" onclick="'admin/reset_workers');">reset workers</a>
Supports Markdown
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