Supervisor/supervisor — Issue #87: Setting stdout_logfile to a directory corrupts process state
Author: gnosek
Created: 2012-02-13 16:06:57+00:00
State: open

When a process has its stdout_logfile mistakenly set to a directory (instead of a file), it raises an exception during startup and ends up in an invalid state:

Traceback (most recent call last):
File ".../supervisor/xmlrpc.py", line 65, in more
value = self.callback()
File ".../supervisor/rpcinterface.py", line 281, in startit
process.spawn()
File ".../supervisor/process.py", line 212, in spawn
self.dispatchers, self.pipes = self.config.make_dispatchers(self)
File ".../supervisor/options.py", line 1672, in make_dispatchers
dispatchers[stdout_fd] = POutputDispatcher(proc, etype, stdout_fd)
File .../supervisor/dispatchers.py", line 98, in __init__
backups=backups)
File ".../supervisor/options.py", line 434, in getLogger
backups, stdout)
File ".../supervisor/loggers.py", line 339, in getLogger
handlers.append(RotatingFileHandler(filename,'a',maxbytes,backups))
File ".../supervisor/loggers.py", line 170, in __init__
self.stream = self.stream or open(filename, mode)
IOError: [Errno 21] Is a directory: '...'
2012-02-13 16:33:28,858 INFO success: ... entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
^C2012-02-13 16:40:25,063 WARN received SIGINT indicating exit request
2012-02-13 16:40:25,063 INFO waiting for ... to die
2012-02-13 16:40:29,062 INFO waiting for ... to die
2012-02-13 16:40:33,061 INFO waiting for ... to die
2012-02-13 16:40:37,061 INFO waiting for ... to die
2012-02-13 16:40:41,060 INFO waiting for ... to die

`supervisor` fails to shut down (`waitpid(0, ...)` returns -ECHILD repeatedly) and the only way to get going is to SIGKILL it and restart it.

`supervisorctl status` shows the process as:

... RUNNING pid 0, uptime 0:03:24

which is clearly bogus.

Tested on git head as of commit 5d8a8bf6fae5e21e9eb78a2c105b16acda297aa6.