3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-11-24 03:29:28 +01:00

control: mark rehash and shutdown as public

This commit is contained in:
James Lu 2017-07-12 21:50:20 -07:00
parent 22e6992770
commit 74f68c2176
2 changed files with 7 additions and 7 deletions

View File

@ -21,7 +21,7 @@ def remove_network(ircobj):
del world.networkobjects[ircobj.name] del world.networkobjects[ircobj.name]
def _print_remaining_threads(): 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. # Remove our pid file.
@ -47,7 +47,7 @@ def _kill_plugins(irc=None):
atexit.register(_remove_pid) atexit.register(_remove_pid)
atexit.register(_kill_plugins) atexit.register(_kill_plugins)
def _shutdown(irc=None): def shutdown(irc=None):
"""Shuts down the Pylink daemon.""" """Shuts down the Pylink daemon."""
global tried_shutdown global tried_shutdown
if tried_shutdown: # We froze on shutdown last time, so immediately abort. if tried_shutdown: # We froze on shutdown last time, so immediately abort.
@ -77,12 +77,12 @@ def _shutdown(irc=None):
def sigterm_handler(signo, stack_frame): def sigterm_handler(signo, stack_frame):
"""Handles SIGTERM and SIGINT gracefully by shutting down the PyLink daemon.""" """Handles SIGTERM and SIGINT gracefully by shutting down the PyLink daemon."""
log.info("Shutting down on signal %s." % signo) log.info("Shutting down on signal %s." % signo)
_shutdown() shutdown()
signal.signal(signal.SIGTERM, sigterm_handler) signal.signal(signal.SIGTERM, sigterm_handler)
signal.signal(signal.SIGINT, sigterm_handler) signal.signal(signal.SIGINT, sigterm_handler)
def _rehash(): def rehash():
"""Rehashes the PyLink daemon.""" """Rehashes the PyLink daemon."""
log.info('Reloading PyLink configuration...') log.info('Reloading PyLink configuration...')
old_conf = conf.conf.copy() old_conf = conf.conf.copy()
@ -142,7 +142,7 @@ if os.name == 'posix':
def sigusr1_handler(_signo, _stack_frame): def sigusr1_handler(_signo, _stack_frame):
"""Handles SIGUSR1 by rehashing the PyLink daemon.""" """Handles SIGUSR1 by rehashing the PyLink daemon."""
log.info("SIGUSR1 received, reloading config.") log.info("SIGUSR1 received, reloading config.")
_rehash() rehash()
signal.signal(signal.SIGUSR1, sigusr1_handler) signal.signal(signal.SIGUSR1, sigusr1_handler)
signal.signal(signal.SIGHUP, sigterm_handler) signal.signal(signal.SIGHUP, sigterm_handler)

View File

@ -67,7 +67,7 @@ def shutdown(irc, source, args):
log.info('(%s) SHUTDOWN requested by "%s!%s@%s", exiting...', irc.name, u.nick, log.info('(%s) SHUTDOWN requested by "%s!%s@%s", exiting...', irc.name, u.nick,
u.ident, u.host) u.ident, u.host)
control._shutdown(irc=irc) control.shutdown(irc=irc)
@utils.add_cmd @utils.add_cmd
def load(irc, source, args): def load(irc, source, args):
@ -194,7 +194,7 @@ def rehash(irc, source, args):
Note: plugins must be manually reloaded.""" Note: plugins must be manually reloaded."""
permissions.checkPermissions(irc, source, ['core.rehash']) permissions.checkPermissions(irc, source, ['core.rehash'])
try: try:
control._rehash() control.rehash()
except Exception as e: # Something went wrong, abort. except Exception as e: # Something went wrong, abort.
log.exception("Error REHASHing config: ") log.exception("Error REHASHing config: ")
irc.reply("Error loading configuration file: %s: %s" % (type(e).__name__, e)) irc.reply("Error loading configuration file: %s: %s" % (type(e).__name__, e))