3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-11-30 14:49:28 +01:00

service_support: fix service respawn on KILL

This commit is contained in:
James Lu 2017-05-12 18:45:27 -07:00
parent 457325024a
commit 7e51d3a7f5

View File

@ -100,10 +100,18 @@ utils.add_hook(handle_endburst, 'ENDBURST')
def handle_kill(irc, source, command, args): def handle_kill(irc, source, command, args):
"""Handle KILLs to PyLink service bots, respawning them as needed.""" """Handle KILLs to PyLink service bots, respawning them as needed."""
target = args['target'] target = args['target']
userdata = args.get('userdata')
sbot = irc.getServiceBot(target) sbot = irc.getServiceBot(target)
if sbot: servicename = None
spawn_service(irc, source, command, {'name': sbot.name})
return if userdata and hasattr(userdata, 'service'): # Look for the target's service name attribute
servicename = userdata.service
elif sbot: # Or their service bot instance
servicename = sbot.name
if servicename:
log.debug('(%s) services_support: respawning service %s after KILL.', irc.name, servicename)
spawn_service(irc, source, command, {'name': servicename})
utils.add_hook(handle_kill, 'KILL') utils.add_hook(handle_kill, 'KILL')
def handle_kick(irc, source, command, args): def handle_kick(irc, source, command, args):