From 5b73e0a69108ceca375ba6787c6123bdb41f38ef Mon Sep 17 00:00:00 2001 From: James Lu Date: Fri, 12 May 2017 18:45:27 -0700 Subject: [PATCH] service_support: fix service respawn on KILL (cherry picked from commit 7e51d3a7f5b184e3edafdd55c5f834177fe44b3a) --- coremods/service_support.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/coremods/service_support.py b/coremods/service_support.py index 103517b..a942c1a 100644 --- a/coremods/service_support.py +++ b/coremods/service_support.py @@ -94,10 +94,18 @@ utils.add_hook(handle_endburst, 'ENDBURST') def handle_kill(irc, source, command, args): """Handle KILLs to PyLink service bots, respawning them as needed.""" target = args['target'] + userdata = args.get('userdata') sbot = irc.getServiceBot(target) - if sbot: - spawn_service(irc, source, command, {'name': sbot.name}) - return + servicename = None + + 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') def handle_kick(irc, source, command, args):