Skip to content

Commit

Permalink
removed inner reboot call, handle it outside
Browse files Browse the repository at this point in the history
  • Loading branch information
nkoexe committed Nov 21, 2024
1 parent 05a757d commit 3d0a4c9
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 37 deletions.
16 changes: 0 additions & 16 deletions sostituzioni/control/configurazione.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@
or ROOT_PATH / "database" / "configurazione.json.template"
)

SYSTEMD_SERVICE = os.getenv("SCUOLASYNC_SERVICE") or "scuolasync.service"


# error caught in model/app.py to enter setup mode
# this will reimport the module without loading the default config file
if not CONFIG_FILE.exists() and "SCUOLASYNC_SETUP" not in os.environ:
Expand Down Expand Up @@ -606,15 +603,6 @@ def __init__(self):

if os.name == "nt":
self.shell_commands["update"] = ["git", "pull"]
self.shell_commands["reboot"] = [
"kill",
"-9",
str(os.getpid()),
"&&",
"python",
"-m",
"sostituzioni",
]
self.shell_commands["get_version"] = [
"git",
"rev-parse",
Expand All @@ -628,11 +616,7 @@ def __init__(self):
"main",
]
else:
if which("systemctl") is None:
logger.error("Systemctl non trovato.")

self.shell_commands["update"] = ["git", "pull"]
self.shell_commands["reboot"] = ["systemctl", "restart", SYSTEMD_SERVICE]
self.shell_commands["get_version"] = [
"git",
"rev-parse",
Expand Down
3 changes: 2 additions & 1 deletion sostituzioni/view/impostazioni/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ def update():
@login_required
@role_required("impostazioni.write")
def reboot():
subprocess.Popen(configurazione.shell_commands["reboot"], cwd=os.getcwd())
# reboot is handled externally. The process exits and is restarted by systemd or others
exit(0)


# //////////////////////////////
Expand Down
21 changes: 1 addition & 20 deletions sostituzioni/view/impostazioni/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,23 +146,4 @@ def version():
@login_required
@role_required("impostazioni.write")
def log():
import subprocess
from sostituzioni.control.configurazione import SYSTEMD_SERVICE

return (
subprocess.check_output(
[
"/usr/bin/journalctl",
"--output",
"cat",
"-u",
SYSTEMD_SERVICE,
"-n",
"1000",
"--no-pager",
],
stderr=subprocess.STDOUT,
)
.decode("utf-8")
.replace("\n", "<br>")
)
return 'deprecated'

0 comments on commit 3d0a4c9

Please sign in to comment.