-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
39 lines (32 loc) · 1.01 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# Copyright 2025 Akretion (http://www.akretion.com).
# @author Florian Mounier <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from aiohttp import web
from bootemup.config import config
from bootemup.routes import info, start, stop, logs
from bootemup.tasks import remove_obsolete, stop_inactive
app = web.Application()
if config["server"]["disable_interface"]:
print("Web interface is disabled")
app.add_routes(
[
web.get("/start/{name}", start),
web.get("/start/{name}/boot", start),
web.get("/stop/{name}", stop),
]
+ (
[
web.get("/", info),
web.get("/logs/{name}", logs),
]
if not config["server"]["disable_interface"]
else []
)
)
if not config["server"]["disable_background_tasks"]:
app.cleanup_ctx.append(remove_obsolete)
app.cleanup_ctx.append(stop_inactive)
else:
print("Background tasks are disabled")
if __name__ == "__main__":
web.run_app(app, port=1212)