We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent b163a0c commit 89ac0abCopy full SHA for 89ac0ab
1 file changed
core/setting/core.py
@@ -73,11 +73,15 @@ def restart_openvpn() -> None:
73
"""Restart the OpenVPN service with systemctl"""
74
try:
75
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"
+ import subprocess
+
+ subprocess.run(
79
+ ["/usr/bin/systemctl", "restart", "openvpn-server@server"],
80
+ check=True,
81
+ timeout=30,
82
)
- child.expect(pexpect.EOF)
83
logger.info("OpenVPN service restarted successfully.")
84
+ except subprocess.TimeoutExpired:
85
+ logger.error("Timeout while restarting OpenVPN service")
86
except Exception as e:
87
logger.error(f"Error restarting OpenVPN service: {e}")
0 commit comments