mirror of
https://github.com/GNS3/gns3-server
synced 2024-11-30 20:28:08 +00:00
Use SIGBREAK to stop VPCS on Windows.
This commit is contained in:
parent
3d6ec140b7
commit
72b204dfe6
@ -580,6 +580,7 @@ class IOU(IModule):
|
||||
ignore_ports=self._allocated_udp_ports)
|
||||
except Exception as e:
|
||||
self.send_custom_error(str(e))
|
||||
return
|
||||
|
||||
self._allocated_udp_ports.append(port)
|
||||
log.info("{} [id={}] has allocated UDP port {} with host {}".format(iou_instance.name,
|
||||
|
@ -494,6 +494,7 @@ class VPCS(IModule):
|
||||
ignore_ports=self._allocated_udp_ports)
|
||||
except Exception as e:
|
||||
self.send_custom_error(str(e))
|
||||
return
|
||||
|
||||
self._allocated_udp_ports.append(port)
|
||||
log.info("{} [id={}] has allocated UDP port {} with host {}".format(vpcs_instance.name,
|
||||
|
@ -21,6 +21,7 @@ order to run an VPCS instance.
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
import subprocess
|
||||
import signal
|
||||
import shutil
|
||||
@ -343,11 +344,14 @@ class VPCSDevice(object):
|
||||
log.info("starting VPCS: {}".format(self._command))
|
||||
self._vpcs_stdout_file = os.path.join(self._working_dir, "vpcs.log")
|
||||
log.info("logging to {}".format(self._vpcs_stdout_file))
|
||||
if sys.platform.startswith("win32"):
|
||||
flags = subprocess.CREATE_NEW_PROCESS_GROUP
|
||||
with open(self._vpcs_stdout_file, "w") as fd:
|
||||
self._process = subprocess.Popen(self._command,
|
||||
stdout=fd,
|
||||
stderr=subprocess.STDOUT,
|
||||
cwd=self._working_dir)
|
||||
cwd=self._working_dir,
|
||||
creationflags=flags)
|
||||
log.info("VPCS instance {} started PID={}".format(self._id, self._process.pid))
|
||||
self._started = True
|
||||
except OSError as e:
|
||||
@ -363,7 +367,11 @@ class VPCSDevice(object):
|
||||
# stop the VPCS process
|
||||
if self.is_running():
|
||||
log.info("stopping VPCS instance {} PID={}".format(self._id, self._process.pid))
|
||||
self._process.send_signal(signal.SIGTERM) # send SIGTERM will stop VPCS
|
||||
if sys.platform.startswith("win32"):
|
||||
self._process.send_signal(signal.CTRL_BREAK_EVENT)
|
||||
else:
|
||||
self._process.terminate()
|
||||
|
||||
self._process.wait()
|
||||
|
||||
self._process = None
|
||||
|
Loading…
Reference in New Issue
Block a user