mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2025-03-18 20:39:46 +00:00
refactor(service): break out sync rebuilding
This commit is contained in:
parent
f333e791e1
commit
534d965cab
1 changed files with 13 additions and 3 deletions
|
@ -63,9 +63,13 @@ def check_running_status(job: Job, unit_name: str):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
@huey.task()
|
def rebuild_system(job: Job, upgrade: bool = False):
|
||||||
def rebuild_system_task(job: Job, upgrade: bool = False):
|
"""
|
||||||
"""Rebuild the system"""
|
Broken out to allow calling it synchronously.
|
||||||
|
We cannot just block until task is done because it will require a second worker
|
||||||
|
Which we do not have
|
||||||
|
"""
|
||||||
|
|
||||||
unit_name = "sp-nixos-upgrade.service" if upgrade else "sp-nixos-rebuild.service"
|
unit_name = "sp-nixos-upgrade.service" if upgrade else "sp-nixos-rebuild.service"
|
||||||
try:
|
try:
|
||||||
command = ["systemctl", "start", unit_name]
|
command = ["systemctl", "start", unit_name]
|
||||||
|
@ -124,3 +128,9 @@ def rebuild_system_task(job: Job, upgrade: bool = False):
|
||||||
status=JobStatus.ERROR,
|
status=JobStatus.ERROR,
|
||||||
status_text=str(e),
|
status_text=str(e),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@huey.task()
|
||||||
|
def rebuild_system_task(job: Job, upgrade: bool = False):
|
||||||
|
"""Rebuild the system"""
|
||||||
|
rebuild_system(job, upgrade)
|
||||||
|
|
Loading…
Add table
Reference in a new issue