mirror of
https://github.com/GNS3/gns3-server
synced 2024-12-26 00:38:10 +00:00
Merge pull request #584 from GNS3/kill_ghosts
Kill ghosts process at startup (Dynamips, VPCS, Ubridge)
This commit is contained in:
commit
8296621320
@ -26,6 +26,7 @@ import datetime
|
|||||||
import sys
|
import sys
|
||||||
import locale
|
import locale
|
||||||
import argparse
|
import argparse
|
||||||
|
import psutil
|
||||||
import asyncio
|
import asyncio
|
||||||
|
|
||||||
from gns3server.server import Server
|
from gns3server.server import Server
|
||||||
@ -180,6 +181,21 @@ def pid_lock(path):
|
|||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
|
def kill_ghosts():
|
||||||
|
"""
|
||||||
|
Kill process from previous GNS3 session
|
||||||
|
"""
|
||||||
|
detect_process = ["vpcs", "ubridge", "dynamips"]
|
||||||
|
for proc in psutil.process_iter():
|
||||||
|
try:
|
||||||
|
name = proc.name().lower().split(".")[0]
|
||||||
|
if name in detect_process:
|
||||||
|
proc.kill()
|
||||||
|
log.warning("Killed ghost process %s", name)
|
||||||
|
except (psutil.NoSuchProcess, psutil.AccessDenied):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def run():
|
def run():
|
||||||
args = parse_arguments(sys.argv[1:])
|
args = parse_arguments(sys.argv[1:])
|
||||||
|
|
||||||
@ -189,6 +205,7 @@ def run():
|
|||||||
|
|
||||||
if args.pid:
|
if args.pid:
|
||||||
pid_lock(args.pid)
|
pid_lock(args.pid)
|
||||||
|
kill_ghosts()
|
||||||
|
|
||||||
level = logging.INFO
|
level = logging.INFO
|
||||||
if args.debug:
|
if args.debug:
|
||||||
|
Loading…
Reference in New Issue
Block a user