summaryrefslogtreecommitdiff
path: root/tests.as-root
diff options
context:
space:
mode:
authorRichard Maw <richard.maw@gmail.com>2014-08-29 23:18:46 +0100
committerSam Thursfield <sam@afuera.me.uk>2014-09-01 10:26:53 +0000
commit6fba43005c52930ce0175df18122264c2f193448 (patch)
treedb32213293d61774e37298064c4cdcb331a8d9ff /tests.as-root
parent864dff6aa72615a85e3c7180cfd65cacb66867da (diff)
downloadmorph-6fba43005c52930ce0175df18122264c2f193448.tar.gz
deploy: Allow extensions to write to Morph log file
This is achieved by passing it the write end of a pipe, so that the extension has somewhere to write debug messages without clobbering either stdout or stderr. Previously deployment extensions could only display status messages on stdout, which is good for telling the user what is happening but is not useful when trying to do post-mortem debugging, when more information is usually required. This uses the asyncore asynchronous event framework, which is rather specific to sockets, but can be made to work with file descriptors, and has the advantage that it's part of the python standard library. It relies on polling file descriptors, but there's a trick with pipes to use them as a notification that a process has exited: 1. Ensure the write-end of the pipe is only open in the process you want to know when it exits 2. Make sure the pipe's FDs are set in non-blocking read/write mode 3. Call select or poll on the read-end of the file descriptor 4. If select/poll says you can read from that FD, but you get an EOF, then the process has closed it, and if you know it doesn't do that in normal operation, then the process has terminated. It took a few weird hacks to get the async_chat module to unregister its event handlers on EOF, but the result is an event loop that is asleep until the kernel tells it that it has to do something.
Diffstat (limited to 'tests.as-root')
0 files changed, 0 insertions, 0 deletions