mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 05:51:15 +02:00
A notification stream with process monitoring
This commit is contained in:
1 parent
57f5e7a7d9
commit
e9ec5c8a37
15 files changed
+256
-25
No files matched your search
@@ -465,6 +465,8 @@ class IOUVM(BaseVM):
|
||||
env=env)
|
||||
log.info("IOU instance {} started PID={}".format(self._id, self._iou_process.pid))
|
||||
self._started = True
|
||||
self.status = "started"
|
||||
gns3server.utils.asyncio.monitor_process(self._iou_process, self._termination_callback)
|
||||
except FileNotFoundError as e:
|
||||
raise IOUError("Could not start IOU: {}: 32-bit binary support is probably not installed".format(e))
|
||||
except (OSError, subprocess.SubprocessError) as e:
|
||||
@@ -477,6 +479,17 @@ class IOUVM(BaseVM):
|
||||
# connections support
|
||||
yield from self._start_iouyap()
|
||||
|
||||
def _termination_callback(self, returncode):
|
||||
"""
|
||||
Called when the process is killed
|
||||
|
||||
:param returncode: Process returncode
|
||||
"""
|
||||
log.info("IOU process crash return code: %d", returncode)
|
||||
self._terminate_process_iou()
|
||||
self._terminate_process_iouyap()
|
||||
self._ioucon_thread_stop_event.set()
|
||||
|
||||
def _rename_nvram_file(self):
|
||||
"""
|
||||
Before starting the VM, rename the nvram and vlan.dat files with the correct IOU application identifier.
|
||||
@@ -507,6 +520,7 @@ class IOUVM(BaseVM):
|
||||
stderr=subprocess.STDOUT,
|
||||
cwd=self.working_dir)
|
||||
|
||||
gns3server.utils.asyncio.monitor_process(self._iouyap_process, self._termination_callback)
|
||||
log.info("iouyap started PID={}".format(self._iouyap_process.pid))
|
||||
except (OSError, subprocess.SubprocessError) as e:
|
||||
iouyap_stdout = self.read_iouyap_stdout()
|
||||
@@ -615,24 +629,28 @@ class IOUVM(BaseVM):
|
||||
Terminate the IOUYAP process if running.
|
||||
"""
|
||||
|
||||
log.info('Stopping IOUYAP process for IOU VM "{}" PID={}'.format(self.name, self._iouyap_process.pid))
|
||||
try:
|
||||
self._iouyap_process.terminate()
|
||||
# Sometime the process may already be dead when we garbage collect
|
||||
except ProcessLookupError:
|
||||
pass
|
||||
if self._iouyap_process:
|
||||
log.info('Stopping IOUYAP process for IOU VM "{}" PID={}'.format(self.name, self._iouyap_process.pid))
|
||||
try:
|
||||
self._iouyap_process.terminate()
|
||||
# Sometime the process can already be dead when we garbage collect
|
||||
except ProcessLookupError:
|
||||
pass
|
||||
|
||||
def _terminate_process_iou(self):
|
||||
"""
|
||||
Terminate the IOU process if running
|
||||
"""
|
||||
|
||||
log.info('Stopping IOU process for IOU VM "{}" PID={}'.format(self.name, self._iou_process.pid))
|
||||
try:
|
||||
self._iou_process.terminate()
|
||||
# Sometime the process may already be dead when we garbage collect
|
||||
except ProcessLookupError:
|
||||
pass
|
||||
if self._iou_process:
|
||||
log.info('Stopping IOU process for IOU VM "{}" PID={}'.format(self.name, self._iou_process.pid))
|
||||
try:
|
||||
self._iou_process.terminate()
|
||||
# Sometime the process can already be dead when we garbage collect
|
||||
except ProcessLookupError:
|
||||
pass
|
||||
self._started = False
|
||||
self.status = "stopped"
|
||||
|
||||
@asyncio.coroutine
|
||||
def reload(self):
|
||||
|
||||
@@ -541,7 +541,6 @@ def send_recv_loop(epoll, console, router, esc_char, stop_event):
|
||||
else:
|
||||
router.write(buf)
|
||||
finally:
|
||||
log.debug("Finally")
|
||||
router.unregister(epoll)
|
||||
console.unregister(epoll)
|
||||
|
||||
|
||||
Reference in new issue
Block a user