Last active
May 24, 2016 22:05
-
-
Save stefanor/4594437 to your computer and use it in GitHub Desktop.
Playing around with `kill timeout` in Upstart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
description "A stubborn service, for debugging" | |
start on runlevel [2345] | |
stop on runlevel [!2345] | |
kill timeout 30 | |
exec stubborn-test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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