Hello,

I'm using supervisord to run several little monitoring scripts (and
some web applications too).

For simplicity, those monitoring scripts send their logging
information directly to stdout. I've setup supervisord to catch stdout
and redirect it to a log file.

The scripts shutdown when they receive signal SIGTERM or SIGINT and
log some final information just before exiting. Here is a log sample
for illustration:

[Mon Apr 14 02:24:04 2008] Script started
[Mon Apr 14 02:24:04 2008] Tick
[Mon Apr 14 02:24:05 2008] Tick
[Mon Apr 14 02:24:06 2008] Tick
[Mon Apr 14 02:24:07 2008] Script stopped

My problem: When I kill the child process with "supervisorctl stop
myscriptname", the last line "Script stopped" doesn't appear in the
log maintained by supervisord.

If I kill the child process with "kill pid", the last line is
correctly reported in the log.

I guess this is because supervisord checks the pipe from the child
process only *before* killing it, and not after.

Attached is a supervisord sample configuration file (supervisord.conf)
and a sample test script (test.py) in order to reproduce the problem.

Thanks for your help,
And of course, thanks for your beautiful tool!

Nicolas

-- 
Nicolas Grilly - Garden
Conseil - Systèmes décisionnels - Systèmes web
Tel +33 1 45 72 48 78
Mob +33 6 03 00 25 34
www.garden-paris.com

Attachment: supervisord.conf
Description: Binary data

#!/usr/bin/python

import signal
import sys
import time

def main():
    log("Test started")
    signal.signal(signal.SIGTERM, handle_signal)
    signal.signal(signal.SIGINT, handle_signal)
    try:
        while True:
            log("Tick")
            time.sleep(1)
    except SystemExit:
        log("Monitor stopped")

def handle_signal(signal_number, stack_frame):
    log("Received signal %i" % signal_number)
    sys.exit()

def log(message):
    message = '[%s] %s\n' % (time.ctime(), message)
    sys.stdout.write(message)
    sys.stdout.flush()

if __name__ == '__main__':
    main()
_______________________________________________
Supervisor-users mailing list
[email protected]
http://lists.supervisord.org/mailman/listinfo/supervisor-users

Reply via email to