mirror of
https://github.com/jlu5/PyLink.git
synced 2024-11-01 01:09:22 +01:00
core: Properly track whether we should actually remove the PID file
Previously, PyLink spuriously removed PID files even if -n/--no-check-pid was set or if PID file checking caused PyLink to quit
This commit is contained in:
parent
2113f834a3
commit
91659ea992
@ -24,13 +24,16 @@ def _print_remaining_threads():
|
|||||||
log.debug('shutdown(): Remaining threads: %s', ['%s/%s' % (t.name, t.ident) for t in threading.enumerate()])
|
log.debug('shutdown(): Remaining threads: %s', ['%s/%s' % (t.name, t.ident) for t in threading.enumerate()])
|
||||||
|
|
||||||
def _remove_pid():
|
def _remove_pid():
|
||||||
# Remove our pid file.
|
|
||||||
pidfile = "%s.pid" % conf.confname
|
pidfile = "%s.pid" % conf.confname
|
||||||
log.info("Removing PID file %r.", pidfile)
|
if world._should_remove_pid:
|
||||||
try:
|
# Remove our pid file.
|
||||||
os.remove(pidfile)
|
log.info("Removing PID file %r.", pidfile)
|
||||||
except OSError:
|
try:
|
||||||
log.exception("Failed to remove PID file %r, ignoring..." % pidfile)
|
os.remove(pidfile)
|
||||||
|
except OSError:
|
||||||
|
log.exception("Failed to remove PID file %r, ignoring..." % pidfile)
|
||||||
|
else:
|
||||||
|
log.debug('Not removing PID file %s as world._should_remove_pid is False.' % pidfile)
|
||||||
|
|
||||||
def _kill_plugins(irc=None):
|
def _kill_plugins(irc=None):
|
||||||
log.info("Shutting down plugins.")
|
log.info("Shutting down plugins.")
|
||||||
|
@ -50,6 +50,7 @@ def main():
|
|||||||
if not args.no_pid:
|
if not args.no_pid:
|
||||||
with open('%s.pid' % conf.confname, 'w') as f:
|
with open('%s.pid' % conf.confname, 'w') as f:
|
||||||
f.write(str(os.getpid()))
|
f.write(str(os.getpid()))
|
||||||
|
world._should_remove_pid = True
|
||||||
|
|
||||||
# Import plugins first globally, because they can listen for events
|
# Import plugins first globally, because they can listen for events
|
||||||
# that happen before the connection phase.
|
# that happen before the connection phase.
|
||||||
|
3
world.py
3
world.py
@ -33,3 +33,6 @@ fallback_hostname = 'pylink.int'
|
|||||||
# Defines messages to be logged as soon as the log system is set up, for modules like conf that are
|
# Defines messages to be logged as soon as the log system is set up, for modules like conf that are
|
||||||
# initialized before log. This is processed (and then not used again) when the log module loads.
|
# initialized before log. This is processed (and then not used again) when the log module loads.
|
||||||
log_queue = deque()
|
log_queue = deque()
|
||||||
|
|
||||||
|
# Determines whether we have a PID file that needs to be removed.
|
||||||
|
_should_remove_pid = False
|
||||||
|
Loading…
Reference in New Issue
Block a user