This commit is contained in:
Mateusz Gruszczyński
2025-09-05 09:45:42 +02:00
parent 56a462ca9b
commit 3947e590d6
2 changed files with 7 additions and 5 deletions

10
app.py
View File

@@ -74,15 +74,15 @@ def serviceCommand(name: str):
return f"systemctl reload {name}"
def runCmd(cmd: str):
"""Uruchamia komendę w shellu z timeoutem i logowaniem."""
logger.info(f"Exec: {cmd}")
try:
env = os.environ.copy()
env["PATH"] = getCfg("exec_path", DEFAULT_EXEC_PATH) or DEFAULT_EXEC_PATH
out = subprocess.run(
cmd, shell=True, capture_output=True, text=True, timeout=RELOAD_TIMEOUT
cmd, shell=True, capture_output=True, text=True,
timeout=RELOAD_TIMEOUT, env=env
)
stdout = (out.stdout or "").strip()
stderr = (out.stderr or "").strip()
return out.returncode, stdout, stderr
return out.returncode, (out.stdout or "").strip(), (out.stderr or "").strip()
except subprocess.TimeoutExpired:
return 124, "", "Timeout"

View File

@@ -1,6 +1,8 @@
[daemon]
API_TOKEN = apitoken
backup_path= /backup
services = dnsmasq
# opcjonalnie: globalny timeout (sekundy)