mirror of
https://github.com/YunoHost/yunorunner.git
synced 2024-09-03 20:05:52 +02:00
[enh] broadcast new app event
This commit is contained in:
parent
5e9a675921
commit
f6ff9dca83
2 changed files with 25 additions and 0 deletions
6
run.py
6
run.py
|
@ -242,6 +242,11 @@ async def monitor_apps_lists(type="stable"):
|
||||||
random_job_day=random.randint(1, 28),
|
random_job_day=random.randint(1, 28),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
await broadcast({
|
||||||
|
"action": "new_app",
|
||||||
|
"data": model_to_dict(repo),
|
||||||
|
}, "apps")
|
||||||
|
|
||||||
await create_job(app_id, app_list_name, repo, job_command_last_part)
|
await create_job(app_id, app_list_name, repo, job_command_last_part)
|
||||||
|
|
||||||
await asyncio.sleep(3)
|
await asyncio.sleep(3)
|
||||||
|
@ -454,6 +459,7 @@ async def ws_job(request, websocket, job_id):
|
||||||
@app.websocket('/apps-ws')
|
@app.websocket('/apps-ws')
|
||||||
async def ws_apps(request, websocket):
|
async def ws_apps(request, websocket):
|
||||||
subscribe(websocket, "jobs")
|
subscribe(websocket, "jobs")
|
||||||
|
subscribe(websocket, "apps")
|
||||||
|
|
||||||
# I need to do this because peewee strangely fuck up on join and remove the
|
# I need to do this because peewee strangely fuck up on join and remove the
|
||||||
# subquery fields which breaks everything
|
# subquery fields which breaks everything
|
||||||
|
|
|
@ -76,6 +76,25 @@
|
||||||
|
|
||||||
if (action == "init_apps") {
|
if (action == "init_apps") {
|
||||||
app.apps = data;
|
app.apps = data;
|
||||||
|
} else if (action == "new_app") {
|
||||||
|
for (var i = 0; i < app.apps.length; ++i) {
|
||||||
|
if (data.name < app.apps[i].name) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// I need to set everything as null then a first job should be
|
||||||
|
// created right after the app
|
||||||
|
app.apps.splice(i, 0, Object.assign(data, {
|
||||||
|
"job_id": null,
|
||||||
|
"job_name": null,
|
||||||
|
"url_or_path": null,
|
||||||
|
"job_state": null,
|
||||||
|
"log": null,
|
||||||
|
"created_time": null,
|
||||||
|
"started_time": null,
|
||||||
|
"end_time": null,
|
||||||
|
}));
|
||||||
} else if (action == "update_job") {
|
} else if (action == "update_job") {
|
||||||
for (var i = 0; i < app.apps.length; ++i) {
|
for (var i = 0; i < app.apps.length; ++i) {
|
||||||
if (app.apps[i].job_id == data.id) {
|
if (app.apps[i].job_id == data.id) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue