mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2025-01-05 23:54:19 +00:00
fix: debugging
This commit is contained in:
parent
ab1ca6e59c
commit
94456af7d4
|
@ -26,7 +26,7 @@ def rebuild_system_task(job: Job, upgrade: bool = False):
|
|||
Jobs.update(
|
||||
job=job,
|
||||
status=JobStatus.RUNNING,
|
||||
status_text="Rebuilding the system...",
|
||||
status_text="Starting the system rebuild...",
|
||||
)
|
||||
# Get current time to handle timeout
|
||||
start_time = time.time()
|
||||
|
@ -39,26 +39,8 @@ def rebuild_system_task(job: Job, upgrade: bool = False):
|
|||
capture_output=True,
|
||||
text=True,
|
||||
)
|
||||
print(status.stdout.strip())
|
||||
if status.stdout.strip() == "active":
|
||||
log_line = subprocess.run(
|
||||
[
|
||||
"journalctl",
|
||||
"-u",
|
||||
"selfprivacy-upgrade",
|
||||
"-n",
|
||||
"1",
|
||||
"-o",
|
||||
"cat",
|
||||
],
|
||||
check=True,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
).stdout.strip()
|
||||
Jobs.update(
|
||||
job=job,
|
||||
status=JobStatus.RUNNING,
|
||||
status_text=f"Rebuilding the system... Latest log line: {log_line}",
|
||||
)
|
||||
break
|
||||
# Timeount after 5 minutes
|
||||
if time.time() - start_time > 300:
|
||||
|
@ -76,6 +58,7 @@ def rebuild_system_task(job: Job, upgrade: bool = False):
|
|||
status=JobStatus.RUNNING,
|
||||
status_text="Rebuilding the system...",
|
||||
)
|
||||
print("Rebuilding the system...")
|
||||
# Wait for the systemd unit to finish
|
||||
while True:
|
||||
try:
|
||||
|
@ -85,6 +68,7 @@ def rebuild_system_task(job: Job, upgrade: bool = False):
|
|||
capture_output=True,
|
||||
text=True,
|
||||
)
|
||||
print(status.stdout.strip())
|
||||
if status.stdout.strip() == "inactive":
|
||||
Jobs.update(
|
||||
job=job,
|
||||
|
@ -99,6 +83,28 @@ def rebuild_system_task(job: Job, upgrade: bool = False):
|
|||
error="System rebuild failed.",
|
||||
)
|
||||
break
|
||||
elif status.stdout.strip() == "active":
|
||||
print("Geting a log line")
|
||||
log_line = subprocess.run(
|
||||
[
|
||||
"journalctl",
|
||||
"-u",
|
||||
"selfprivacy-upgrade",
|
||||
"-n",
|
||||
"1",
|
||||
"-o",
|
||||
"cat",
|
||||
],
|
||||
check=True,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
).stdout.strip()
|
||||
print(log_line)
|
||||
Jobs.update(
|
||||
job=job,
|
||||
status=JobStatus.RUNNING,
|
||||
status_text=f"Rebuilding the system... Latest log line: {log_line}",
|
||||
)
|
||||
# Timeout of 60 minutes
|
||||
if time.time() - start_time > 3600:
|
||||
Jobs.update(
|
||||
|
@ -107,11 +113,10 @@ def rebuild_system_task(job: Job, upgrade: bool = False):
|
|||
error="System rebuild timed out.",
|
||||
)
|
||||
break
|
||||
time.sleep(5)
|
||||
except subprocess.CalledProcessError:
|
||||
pass
|
||||
|
||||
time.sleep(5)
|
||||
|
||||
except subprocess.CalledProcessError as e:
|
||||
Jobs.update(
|
||||
job=job,
|
||||
|
|
Loading…
Reference in a new issue