mirror of
https://github.com/jlu5/PyLink.git
synced 2024-11-27 21:19:31 +01:00
service_support: fix service respawn on KILL
This commit is contained in:
parent
457325024a
commit
7e51d3a7f5
@ -100,10 +100,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):
|
||||
|
Loading…
Reference in New Issue
Block a user