MCPcopy Create free account
hub / github.com/apache/cloudstack / checkProcessRunningStatus

Function checkProcessRunningStatus

systemvm/debian/root/monitorServices.py:148–173  ·  view source on GitHub ↗
(process_name, pidFile)

Source from the content-addressed store, hash-verified

146 return StatusCodes.FAILED
147
148def checkProcessRunningStatus(process_name, pidFile):
149 printd("checking the process " + process_name)
150 cmd = ''
151 pids = []
152 cmd = 'pidof ' + process_name
153 printd(cmd)
154
155 #cmd = 'service ' + process_name + ' status'
156 pout = Popen(cmd, shell=True, stdout=PIPE)
157 exitStatus = pout.wait()
158 temp_out = pout.communicate()[0].decode()
159
160 #check there is only one pid or not
161 if exitStatus == 0:
162 pids = temp_out.strip().split(' ')
163 printd("pid(s) of process %s are %s " %(process_name, pids))
164
165 #there is more than one process so match the pid file
166 #if not matched set pidFileMatched=False
167 printd("Checking pid file")
168 if isPidMatchPidFile(pidFile, pids) == StatusCodes.SUCCESS:
169 return True,pids
170
171 printd("pid of exit status %s" %exitStatus)
172
173 return False,pids
174
175def restartService(service_name):
176

Callers 1

checkProcessStatusFunction · 0.85

Calls 4

printdFunction · 0.85
isPidMatchPidFileFunction · 0.85
waitMethod · 0.45
decodeMethod · 0.45

Tested by

no test coverage detected