I have an Erlang program that runs in Erlang shell, obviously, and I want to monitor it.
This is what I want:
- When the machine starts the Erlang shell should start up with it, and the program that runs in the shell too.
- If the Erlang shell crashes for some reason it should get restarted.
- You should be able to manually start/stop/restart the Erlang shell.
Example:
/etc/init.d/foobar start
/etc/init.d/foobar stop
/etc/init.d/foobar restart
I haven't started with the whole "restart itself if crash" thing yet, got stuck with the easy thing, or is it easy?
What I have done is this:
Taken the skeleton code from /etc/init.d/skeleton and replaced the PATH, DESC, NAME etc etc... This works, I can do:
/etc/init.d/foobar start
However, I cant stop it... The thing is that I start the Erlang shell with "erl" which is a script that does some fancy things that I dont understand. One thing it does is, it creates a very long and complex process name. It's not just "erl" it's like:
/usr/lib/erlang/erts-5.7.4/bin/beam.smp -- -root /usr/lib/erlang -progname erl -- -home /home/xxx -- .... and some more.
Is there a better way to do this?
OS: Ubuntu 11.04