mirror of
https://github.com/jlu5/PyLink.git
synced 2025-02-17 14:01:03 +01:00
launcher: rename has_pid variable to pid_exists
This name is a lot more descriptive.
This commit is contained in:
parent
874dfaf3f1
commit
dda8a2a081
10
launcher.py
10
launcher.py
@ -25,7 +25,7 @@ def _main():
|
|||||||
# Write and check for an existing PID file unless specifically told not to.
|
# Write and check for an existing PID file unless specifically told not to.
|
||||||
if not args.no_pid:
|
if not args.no_pid:
|
||||||
pidfile = '%s.pid' % conf.confname
|
pidfile = '%s.pid' % conf.confname
|
||||||
has_pid = False
|
pid_exists = False
|
||||||
pid = None
|
pid = None
|
||||||
if os.path.exists(pidfile):
|
if os.path.exists(pidfile):
|
||||||
try:
|
try:
|
||||||
@ -34,22 +34,22 @@ def _main():
|
|||||||
except OSError:
|
except OSError:
|
||||||
log.exception("Could not read PID file %s:", pidfile)
|
log.exception("Could not read PID file %s:", pidfile)
|
||||||
else:
|
else:
|
||||||
has_pid = True
|
pid_exists = True
|
||||||
|
|
||||||
if psutil is not None and os.name == 'posix':
|
if psutil is not None and os.name == 'posix':
|
||||||
# FIXME: Haven't tested this on other platforms, so not turning it on by default.
|
# FIXME: Haven't tested this on other platforms, so not turning it on by default.
|
||||||
try:
|
try:
|
||||||
proc = psutil.Process(pid)
|
proc = psutil.Process(pid)
|
||||||
except psutil.NoSuchProcess: # Process doesn't exist!
|
except psutil.NoSuchProcess: # Process doesn't exist!
|
||||||
has_pid = False
|
pid_exists = False
|
||||||
log.info("Ignoring stale PID %s from PID file %r: no such process exists.", pid, pidfile)
|
log.info("Ignoring stale PID %s from PID file %r: no such process exists.", pid, pidfile)
|
||||||
else:
|
else:
|
||||||
# This PID got reused for something that isn't us?
|
# This PID got reused for something that isn't us?
|
||||||
if not any('pylink' in arg.lower() for arg in proc.cmdline()):
|
if not any('pylink' in arg.lower() for arg in proc.cmdline()):
|
||||||
log.info("Ignoring stale PID %s from PID file %r: process command line %r is not us", pid, pidfile, proc.cmdline())
|
log.info("Ignoring stale PID %s from PID file %r: process command line %r is not us", pid, pidfile, proc.cmdline())
|
||||||
has_pid = False
|
pid_exists = False
|
||||||
|
|
||||||
if pid and has_pid:
|
if pid and pid_exists:
|
||||||
if args.rehash:
|
if args.rehash:
|
||||||
os.kill(pid, signal.SIGUSR1)
|
os.kill(pid, signal.SIGUSR1)
|
||||||
log.info('OK, rehashed PyLink instance %s (config %r)', pid, args.config)
|
log.info('OK, rehashed PyLink instance %s (config %r)', pid, args.config)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user