mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2025-01-22 08:46:37 +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(
|
Jobs.update(
|
||||||
job=job,
|
job=job,
|
||||||
status=JobStatus.RUNNING,
|
status=JobStatus.RUNNING,
|
||||||
status_text="Rebuilding the system...",
|
status_text="Starting the system rebuild...",
|
||||||
)
|
)
|
||||||
# Get current time to handle timeout
|
# Get current time to handle timeout
|
||||||
start_time = time.time()
|
start_time = time.time()
|
||||||
|
@ -39,26 +39,8 @@ def rebuild_system_task(job: Job, upgrade: bool = False):
|
||||||
capture_output=True,
|
capture_output=True,
|
||||||
text=True,
|
text=True,
|
||||||
)
|
)
|
||||||
|
print(status.stdout.strip())
|
||||||
if status.stdout.strip() == "active":
|
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
|
break
|
||||||
# Timeount after 5 minutes
|
# Timeount after 5 minutes
|
||||||
if time.time() - start_time > 300:
|
if time.time() - start_time > 300:
|
||||||
|
@ -76,6 +58,7 @@ def rebuild_system_task(job: Job, upgrade: bool = False):
|
||||||
status=JobStatus.RUNNING,
|
status=JobStatus.RUNNING,
|
||||||
status_text="Rebuilding the system...",
|
status_text="Rebuilding the system...",
|
||||||
)
|
)
|
||||||
|
print("Rebuilding the system...")
|
||||||
# Wait for the systemd unit to finish
|
# Wait for the systemd unit to finish
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
|
@ -85,6 +68,7 @@ def rebuild_system_task(job: Job, upgrade: bool = False):
|
||||||
capture_output=True,
|
capture_output=True,
|
||||||
text=True,
|
text=True,
|
||||||
)
|
)
|
||||||
|
print(status.stdout.strip())
|
||||||
if status.stdout.strip() == "inactive":
|
if status.stdout.strip() == "inactive":
|
||||||
Jobs.update(
|
Jobs.update(
|
||||||
job=job,
|
job=job,
|
||||||
|
@ -99,6 +83,28 @@ def rebuild_system_task(job: Job, upgrade: bool = False):
|
||||||
error="System rebuild failed.",
|
error="System rebuild failed.",
|
||||||
)
|
)
|
||||||
break
|
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
|
# Timeout of 60 minutes
|
||||||
if time.time() - start_time > 3600:
|
if time.time() - start_time > 3600:
|
||||||
Jobs.update(
|
Jobs.update(
|
||||||
|
@ -107,11 +113,10 @@ def rebuild_system_task(job: Job, upgrade: bool = False):
|
||||||
error="System rebuild timed out.",
|
error="System rebuild timed out.",
|
||||||
)
|
)
|
||||||
break
|
break
|
||||||
|
time.sleep(5)
|
||||||
except subprocess.CalledProcessError:
|
except subprocess.CalledProcessError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
time.sleep(5)
|
|
||||||
|
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
Jobs.update(
|
Jobs.update(
|
||||||
job=job,
|
job=job,
|
||||||
|
|
Loading…
Reference in a new issue