mirror of
https://github.com/retspen/webvirtcloud
synced 2026-11-09 11:46:49 +00:00
fix(console): novncd that cannot listen ends with a failure status
websockify logs "Openening socket failed" and calls sys.exit() when its port is taken, so novncd ended with status 0. Under systemd the unit then counts as stopped, not failed: Restart=on-failure does not start it again, systemctl --failed does not list it, and VNC consoles stay down until someone starts it by hand. novncd now ends with status 1 there.
This commit is contained in:
parent
2991afc9b9
commit
e448e60684
2 changed files with 30 additions and 2 deletions
22
console/tests/test_novncd_exit.py
Normal file
22
console/tests/test_novncd_exit.py
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
"""novncd that cannot listen ends with a failure status, which systemd restarts."""
|
||||
|
||||
import socket
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
from django.test import SimpleTestCase
|
||||
|
||||
ROOT = Path(__file__).resolve().parent.parent.parent
|
||||
|
||||
|
||||
class NovncdExitTestCase(SimpleTestCase):
|
||||
def test_a_taken_port_ends_novncd_with_a_failure_status(self):
|
||||
with socket.socket() as taken:
|
||||
taken.bind(("127.0.0.1", 0))
|
||||
taken.listen()
|
||||
port = taken.getsockname()[1]
|
||||
novncd = subprocess.run([sys.executable, str(ROOT / "console" / "novncd"), "-v", "-H", "127.0.0.1",
|
||||
"-p", str(port)], cwd=ROOT, capture_output=True, timeout=60)
|
||||
self.assertNotEqual(novncd.returncode, 0)
|
||||
self.assertIn(b"Openening socket failed", novncd.stderr)
|
||||
Loading…
Add table
Add a link
Reference in a new issue