Skip to content

Commit f9bdbcd

Browse files
committed
Fix bug in reading old pidfile formats when stopping agent.
1 parent 31adfef commit f9bdbcd

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

scalyr_agent/unix_daemon.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,6 @@ def is_running(self):
225225
@rtype: bool
226226
"""
227227
pid = self.__read_pidfile()
228-
# TODO: Add in check for the pid file exists but the process is not running.
229228
return pid is not None
230229

231230
def fail_if_already_running(self):
@@ -270,15 +269,11 @@ def stop_daemon(self, quiet):
270269
@param quiet: If True, the only error information will be printed to stdout and stderr.
271270
"""
272271
# Get the pid from the pidfile
273-
try:
274-
pf = file(self.pidfile, 'r')
275-
pid = int(pf.read().strip())
276-
pf.close()
277-
except IOError:
278-
pid = None
272+
pid = self.__read_pidfile()
279273

280274
if not pid:
281-
message = "The agent does not appear to be running. pidfile %s does not exist.\n"
275+
message = ("The agent does not appear to be running. pidfile %s does not exist or listed process"
276+
" is not running.\n")
282277
sys.stderr.write(message % self.pidfile)
283278
return 0 # not an error in a restart
284279

0 commit comments

Comments
 (0)