mirror of
https://github.com/GNS3/gns3-server.git
synced 2024-12-23 22:52:25 +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)
|
ignore_ports=self._allocated_udp_ports)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.send_custom_error(str(e))
|
self.send_custom_error(str(e))
|
||||||
|
return
|
||||||
|
|
||||||
self._allocated_udp_ports.append(port)
|
self._allocated_udp_ports.append(port)
|
||||||
log.info("{} [id={}] has allocated UDP port {} with host {}".format(iou_instance.name,
|
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)
|
ignore_ports=self._allocated_udp_ports)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.send_custom_error(str(e))
|
self.send_custom_error(str(e))
|
||||||
|
return
|
||||||
|
|
||||||
self._allocated_udp_ports.append(port)
|
self._allocated_udp_ports.append(port)
|
||||||
log.info("{} [id={}] has allocated UDP port {} with host {}".format(vpcs_instance.name,
|
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 os
|
||||||
|
import sys
|
||||||
import subprocess
|
import subprocess
|
||||||
import signal
|
import signal
|
||||||
import shutil
|
import shutil
|
||||||
@ -343,11 +344,14 @@ class VPCSDevice(object):
|
|||||||
log.info("starting VPCS: {}".format(self._command))
|
log.info("starting VPCS: {}".format(self._command))
|
||||||
self._vpcs_stdout_file = os.path.join(self._working_dir, "vpcs.log")
|
self._vpcs_stdout_file = os.path.join(self._working_dir, "vpcs.log")
|
||||||
log.info("logging to {}".format(self._vpcs_stdout_file))
|
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:
|
with open(self._vpcs_stdout_file, "w") as fd:
|
||||||
self._process = subprocess.Popen(self._command,
|
self._process = subprocess.Popen(self._command,
|
||||||
stdout=fd,
|
stdout=fd,
|
||||||
stderr=subprocess.STDOUT,
|
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))
|
log.info("VPCS instance {} started PID={}".format(self._id, self._process.pid))
|
||||||
self._started = True
|
self._started = True
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
@ -363,7 +367,11 @@ class VPCSDevice(object):
|
|||||||
# stop the VPCS process
|
# stop the VPCS process
|
||||||
if self.is_running():
|
if self.is_running():
|
||||||
log.info("stopping VPCS instance {} PID={}".format(self._id, self._process.pid))
|
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.wait()
|
||||||
|
|
||||||
self._process = None
|
self._process = None
|
||||||
|
Loading…
Reference in New Issue
Block a user