Attention une mise à jour du service Gitlab va être effectuée le mardi 30 novembre entre 17h30 et 18h00. Cette mise à jour va générer une interruption du service dont nous ne maîtrisons pas complètement la durée mais qui ne devrait pas excéder quelques minutes. Cette mise à jour intermédiaire en version 14.0.12 nous permettra de rapidement pouvoir mettre à votre disposition une version plus récente.

Commit 88706dd8 authored by marc duez's avatar marc duez
Browse files

Merge branch 'feature-s/3554-reset-workers' into 'dev'

server/admin: Restart workers

Closes #3554

See merge request !909
parents 6c9a9b9f fc7f1954
Pipeline #222297 passed with stages
in 76 minutes and 33 seconds
......@@ -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"
......@@ -49,9 +49,9 @@ def monitor():
return dict (worker = len(db().select(db.scheduler_worker.ALL)),
queued = len(db(db.scheduler_task.status=='QUEUED').select()),
assigned = len(db(db.scheduler_task.status=='ASSIGNED').select()),
running = len(db(db.scheduler_task.status=='RUNNING').select()),
queued = len(db(db.scheduler_task.status==QUEUED).select()),
assigned = len(db(db.scheduler_task.status==ASSIGNED).select()),
running = len(db(db.scheduler_task.status==RUNNING).select()),
last_results = last_results)
......@@ -194,4 +194,15 @@ 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()
scheduler.die()
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