mirror of
https://github.com/YunoHost/yunorunner.git
synced 2024-09-03 20:05:52 +02:00
[enh] broadcast new job creation
This commit is contained in:
parent
5461bd996d
commit
7a201a530e
2 changed files with 14 additions and 1 deletions
13
run.py
13
run.py
|
@ -68,7 +68,7 @@ async def initialize_app_list():
|
|||
)
|
||||
|
||||
print(f"Schedule a new build for {app_id}")
|
||||
Job.create(
|
||||
job = Job.create(
|
||||
name=f"{app_id} stable",
|
||||
url_or_path=repo.url,
|
||||
target_revision=app_data["git"]["revision"],
|
||||
|
@ -76,6 +76,12 @@ async def initialize_app_list():
|
|||
state="scheduled",
|
||||
)
|
||||
|
||||
print(job)
|
||||
await broadcast({
|
||||
"action": "new_job",
|
||||
"data": model_to_dict(job),
|
||||
}, "jobs")
|
||||
|
||||
|
||||
async def jobs_dispatcher():
|
||||
if Worker.select().count() == 0:
|
||||
|
@ -249,6 +255,11 @@ async def api_new_job(request):
|
|||
|
||||
print(f"Request to add new job '{job.name}' {job}")
|
||||
|
||||
await broadcast({
|
||||
"action": "new_job",
|
||||
"data": model_to_dict(job),
|
||||
}, "jobs")
|
||||
|
||||
return response.text("ok")
|
||||
|
||||
|
||||
|
|
|
@ -59,6 +59,8 @@
|
|||
return;
|
||||
}
|
||||
}
|
||||
} else if (action == "new_job") {
|
||||
app.jobs.splice(0, 0, data);
|
||||
}
|
||||
};
|
||||
})()
|
||||
|
|
Loading…
Add table
Reference in a new issue