Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@stefanor
Last active May 24, 2016 22:05
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stefanor/4594437 to your computer and use it in GitHub Desktop.
Save stefanor/4594437 to your computer and use it in GitHub Desktop.
Playing around with `kill timeout` in Upstart
description "A stubborn service, for debugging"
start on runlevel [2345]
stop on runlevel [!2345]
kill timeout 30
exec stubborn-test
description "A stubborn service, for debugging"
start on runlevel [2345]
stop on runlevel [!2345]
kill timeout 30
exec start-stop-daemon --start -c www-data --exec /usr/local/bin/stubborn-test
#!/usr/bin/env python
import signal
import time
signals = {}
log = None
def handler(sig, frame):
log.write('%s %s\n' % (time.time(), signals[sig]))
def main():
global signals, log
log = open('/var/log/stubborn-test.log', 'a', 0)
signals = dict((getattr(signal, name), name)
for name in dir(signal)
if name.startswith('SIG')
and not name.startswith('SIG_')
and name not in ('SIGSTOP', 'SIGKILL'))
for sig in signals.keys():
signal.signal(sig, handler)
while True:
log.write('%s\n' % time.time())
time.sleep(1)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment