[erlang-questions] managing OS processes

Garrett Smith <>
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 [1] 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
like runit.

http://smarden.org/runit

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:

http://smarden.org/runit/runsv.8.html

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.

Garrett



More information about the erlang-questions mailing list