Skip to content

Commit 89ac0ab

Browse files
committed
fix: restart core
1 parent b163a0c commit 89ac0ab

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

core/setting/core.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,15 @@ def restart_openvpn() -> None:
7373
"""Restart the OpenVPN service with systemctl"""
7474
try:
7575
logger.info("Restarting OpenVPN service...")
76-
# Use pexpect to restart the OpenVPN service
77-
child = pexpect.spawn(
78-
"systemctl restart openvpn-server@server", encoding="utf-8"
76+
import subprocess
77+
78+
subprocess.run(
79+
["/usr/bin/systemctl", "restart", "openvpn-server@server"],
80+
check=True,
81+
timeout=30,
7982
)
80-
child.expect(pexpect.EOF)
8183
logger.info("OpenVPN service restarted successfully.")
84+
except subprocess.TimeoutExpired:
85+
logger.error("Timeout while restarting OpenVPN service")
8286
except Exception as e:
8387
logger.error(f"Error restarting OpenVPN service: {e}")

0 commit comments

Comments
 (0)