Safe Haskell | None |
---|---|
Language | Haskell98 |
Synopsis
- data ProcessTracker
- initProcessTracker :: IO ProcessTracker
- data MonitoredProcess
- monitorProcess :: (ByteString -> IO ()) -> ProcessTracker -> Maybe ByteString -> ByteString -> ByteString -> [ByteString] -> [(ByteString, ByteString)] -> (ByteString -> IO ()) -> (ExitCode -> IO Bool) -> IO MonitoredProcess
- terminateMonitoredProcess :: MonitoredProcess -> IO ()
- printStatus :: MonitoredProcess -> IO Text
Process tracking
Ensure that child processes are killed, regardless of how the parent process exits.
The technique used here is:
- Create a pipe.
- Fork a new child process that listens on the pipe.
- In the current process, send updates about processes that should be auto-killed.
- When the parent process dies, listening on the pipe in the child process will get an EOF.
- When the child process receives that EOF, it kills all processes it was told to auto-kill.
This code was originally written for Keter, but was moved to unix-process conduit in the 0.2.1 release.
Types
data ProcessTracker Source #
Represents the child process which handles process cleanup.
Since 0.2.1
Functions
initProcessTracker :: IO ProcessTracker Source #
Fork off the child cleanup process.
This will ideally only be run once for your entire application.
Since 0.2.1
Monitored process
data MonitoredProcess Source #
Abstract type containing information on a process which will be restarted.
:: (ByteString -> IO ()) | log |
-> ProcessTracker | |
-> Maybe ByteString | setuid |
-> ByteString | executable |
-> ByteString | working directory |
-> [ByteString] | command line parameter |
-> [(ByteString, ByteString)] | environment |
-> (ByteString -> IO ()) | |
-> (ExitCode -> IO Bool) | should we restart? |
-> IO MonitoredProcess |
Run the given command, restarting if the process dies.
terminateMonitoredProcess :: MonitoredProcess -> IO () Source #
Terminate the process and prevent it from being restarted.
printStatus :: MonitoredProcess -> IO Text Source #