mirror of
https://github.com/YunoHost/yunorunner.git
synced 2024-09-03 20:05:52 +02:00
[enh] new api entry point to restart a job
This commit is contained in:
parent
662cc0596f
commit
f1d9623d8b
1 changed files with 18 additions and 0 deletions
18
run.py
18
run.py
|
@ -481,6 +481,24 @@ async def api_stop_job(request, job_id):
|
|||
raise Exception(f"Tryed to cancel a job with an unknown state: {job.state}")
|
||||
|
||||
|
||||
@app.route("/api/job/<job_id:int>/restart", methods=['POST'])
|
||||
async def api_restart_job(request, job_id):
|
||||
api_logger.info(f"Request to restart job {job_id}")
|
||||
await api_stop_job(request, job_id)
|
||||
|
||||
# no need to check if job existss, api_stop_job will do it for us
|
||||
job = Job.select().where(Job.id == job_id)[0]
|
||||
job.state = "scheduled"
|
||||
job.save()
|
||||
|
||||
await broadcast({
|
||||
"action": "update_job",
|
||||
"data": data,
|
||||
}, ["jobs", f"job-{job_id}"])
|
||||
|
||||
return response.text("ok")
|
||||
|
||||
|
||||
@app.route('/job/<job_id>')
|
||||
@jinja.template('job.html')
|
||||
async def job(request, job_id):
|
||||
|
|
Loading…
Add table
Reference in a new issue