views:

444

answers:

2

I have a python script which manages an Erlang daemon. Everything works fine when used through a shell once the system is initialized.

Now, when I included the same script under "/etc/init.d" and with the symlinks properly set in "/etc/rcX.d", the python script still works but my Erlang daemon fails to start and leaves no discernible traces (e.g. crash_dump, dmesg etc.)

I also tried setting the environment variable "HOME" through 'erl -env HOME /root' and still no luck.

Any clues?

+5  A: 

To manually run the script the same way the system does, use service daemon start if you have that command, or else try

cd /
env -i LANG="$LANG" PATH="$PATH" TERM="$TERM" /etc/init.d/daemon start

That forces the script to run with a known, minimal environment just like it would at startup.

John Kugelman
Great tip! Thanks a million!I was able to diagnose the problem in a flash. It seems that 'erl -env HOME /root' isn't enough to set the environment for erl. The environment var "HOME" must be set for 'erl' itself i.e. in the python script using subprocess.Popen() the parameter 'env' must be used to setup a full environment.
jldupont
A: 

Thanks for this answer - I was having a devil of a time starting the "Alice" RESTful interface to rabbitmq on startup. The key was using 'env HOME=/root /path/to/alice/startup/script' in my init script.

Russell Borogove