Add a stop engine call
Add a call to stop engine, this function just sets the enabled field to false, and psutil terminates the process (equivalent to what we do now). Also add psutil to requirements Change-Id: Idc3edb2bf1c9ed55d7d77973c59e3d3562e2ad8b
This commit is contained in:
parent
81a9042ff1
commit
47e35d1d2c
|
@ -18,7 +18,9 @@
|
|||
import argparse
|
||||
import logging
|
||||
import os
|
||||
import psutil
|
||||
import tempfile
|
||||
import time
|
||||
|
||||
from engine import Engine
|
||||
from entropy import utils
|
||||
|
@ -119,6 +121,18 @@ def start_engine(args):
|
|||
return
|
||||
|
||||
|
||||
def stop_engine(args):
|
||||
LOG.info("Stopping engine %s", args.name)
|
||||
# Grab engine config file, set our engine to disabled
|
||||
pid = utils.disable_engine(args.name, engine_cfg)
|
||||
try:
|
||||
p = psutil.Process(pid)
|
||||
time.sleep(5)
|
||||
p.terminate()
|
||||
except psutil.NoSuchProcess:
|
||||
LOG.exception("No running engine %s", args.name)
|
||||
|
||||
|
||||
def parse():
|
||||
parser = argparse.ArgumentParser(description='entropy')
|
||||
subparsers = parser.add_subparsers(dest='command',
|
||||
|
@ -155,6 +169,12 @@ def parse():
|
|||
help='path to engine cfg')
|
||||
scheduler_parser.set_defaults(func=start_engine)
|
||||
|
||||
stop_engine_parser = subparsers.add_parser('stop-engine',
|
||||
help='Stop an entropy engine')
|
||||
stop_engine_parser.add_argument('-n', dest='name',
|
||||
help="Name of engine to stop")
|
||||
stop_engine_parser.set_defaults(func=stop_engine)
|
||||
|
||||
args = parser.parse_args()
|
||||
args.func(args)
|
||||
|
||||
|
|
|
@ -9,3 +9,4 @@ stevedore>0.10
|
|||
watchdog>=0.7.1
|
||||
futures>=2.1.6
|
||||
six>=1.6.1
|
||||
psutil>=1.1.1,<2.0.0
|
||||
|
|
Loading…
Reference in New Issue