CO - Bug fixed, kill application

community
Steve L. Nyemba 7 years ago
parent b831586a97
commit 677f037adf

@ -15,6 +15,7 @@ from threading import Thread
import os
import shutil
import subprocess
from monitor import ProcessCounter
from utils.transport import QueueListener, QueueWriter, QueueReader
from utils.params import PARAMS
@ -39,13 +40,14 @@ class Actor():
print e
return o
def __init__(self):
"""
Initializing the class with configuration. The configuration will be specific to each subclass
@param args arguments the class needs to be configured
"""
pass
def getIdentifier(self):
return self.__class__.__name__.lower()
"""
Initializing the class with configuration. The configuration will be specific to each subclass
@param args arguments the class needs to be configured
"""
def init(self,args):
self.config = args
@ -57,23 +59,18 @@ class Actor():
def execute(self,cmd):
stream = None
try:
subprocess.call (cmd,shell=False)
# subprocess.call (cmd,shell=False)
out = subprocess.Popen(cmd,stdout=subprocess.PIPE)
print out
#stream = handler.communicate()[0]
except Exception,e:
pass
# def run(self):
# if self.item is not None:
# self.process(self.item)
"""
Sending a message to a queue with parameters to,from,content
"""
def post(self,**args):
pass
class Apps(Actor) :
"""
This class is designed to handle application, restart, if need be.
conf{app-name:{args}}
This class is designed to handle application, restart, if need be.
conf{app-name:{args}}
"""
def __init__(self):
Actor.__init__(self)
@ -106,7 +103,7 @@ class Apps(Actor) :
app = items[0]
args = self.config[app]
cmd = " ".join([app,args,"&"])
cmd = " ".join([app,args,"&" ])
self.execute([app,args])
print [app,args]
@ -115,9 +112,10 @@ class Apps(Actor) :
kill processes given the name, The function will not be case sensitive and partial names are accepted
@NOTE: Make sure the reference to the app is not ambiguous
"""
args = "".join(["ps -eo pid,command|grep -E -i ",name.lower(),'|grep -E "^ {0,}[0-9]+" -o -m 1|xargs kill -9'])
self.execute([args ])
print args
args = "".join(['ps -eo pid,command|grep -E -i "',name.lower(),'"|grep -E "^ {0,}[0-9]+" -o|xargs kill -9'])
#self.execute([args])
subprocess.call([args],shell=True)
def analyze(self,logs) :
"""
This function is designed to analyze a few logs and take appropriate action

Loading…
Cancel
Save