mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-12-24 18:34:18 +00:00
Add rudimentary job handler
This commit is contained in:
parent
c2139500e2
commit
bb2b0294fa
@ -3,6 +3,7 @@ from . import scheduler
|
||||
from flask_login import current_user, login_required
|
||||
from .. import background_scheduler
|
||||
import json
|
||||
import subprocess
|
||||
|
||||
|
||||
@scheduler.route('/')
|
||||
@ -17,6 +18,22 @@ def scheduler():
|
||||
},
|
||||
'status': 'queued'
|
||||
}
|
||||
job = background_scheduler.add_job(print, trigger='date', args=[job])
|
||||
print(background_scheduler.get_jobs())
|
||||
job = background_scheduler.add_job(process_job, trigger='date', args=[job])
|
||||
print('### New job added for scheduling ###')
|
||||
print(job)
|
||||
return render_template('scheduler/index.html.j2', title='Scheduler')
|
||||
|
||||
|
||||
def process_job(job):
|
||||
input_dir = '/home/pjentsch/%s/input' % job['service']
|
||||
output_dir = '/home/pjentsch/%s/output' % job['service']
|
||||
|
||||
job['status'] = 'running'
|
||||
print('### Job status changed ###')
|
||||
print(job)
|
||||
|
||||
subprocess.run([job['service'], '-i', input_dir, '-l', job['service_args']['lang'], '-o', output_dir, '--keep-intermediates'])
|
||||
|
||||
job['status'] = 'finished'
|
||||
print('### Job status changed ###')
|
||||
print(job)
|
||||
|
Loading…
Reference in New Issue
Block a user