[erlang-questions] managing OS processes
Tue May 29 19:15:00 CEST 2012
On Sat, May 26, 2012 at 4:06 AM, Benoit Chesneau <> wrote:
> I'm trying to find a way to manage some os processes launched from
> Erlang. For example I need to relaunch them when the external process
> die for an unknown reason or send an HUP signal or just stop the
> external process.
> For now I'm using erlang ports to open an external process and detect
> when it die. I also send signals using the `os:cmd` and and always
> send a SIGKILL signal using the `os:cmd`before closing the port. But
> is there a better way to do that? Maybe a module somewhere ? I saw
> erlexec  but it doesn't seem to be maintained since a while.
I think it'd be great to get this into OTP core, but until that
functionality is a) implemented and b) has demonstrated solid
operations across range of platforms, I'm inclined to use something
Runit will "daemonize" for you (wants child processes to run in the
foreground) and provides a simple interface for sending signals to a
child process. E.g. to send KILL to a process (shell example):
printf k > $SERVICE/supervise/control
The control scheme is described here:
It's not as tightly integrated as a futuristic open_port might be.
E.g. if you want to detect a pathological case (service flapping, app
errors, etc.) you'd have to poll the environment (track pid changes,
scan logs, etc.) But there are sometimes advantages to keeping OS
process supervision and monitoring at arms length.
More information about the erlang-questions