Starting Nitrogen Web framework at boot time

169 Views Asked by At

I have always started nitrogen to run as a daemon using the command below:

sudo /home/someuser/myapp/bin/nitrogen start

It works well but i have to repeat the same activity should the server reboot.

Most web servers by default start at boot time. When nitrogen is started, it starts the underlying Erlang web server. Unfortunately I have not found any single resource talking about starting nitrogen at boot time.

How do you start nitrogen as a daemon at system boot time?

1

There are 1 best solutions below

19
chops On

The easiest solution is to use the /etc/rc.local file. By default, it's empty.

Since rc.local runs as root, you can use it as such (though if you prefer to run Nitrogen as a separate user, using su -c "command" username) is good.

Anyway, the simple solution is to add to your rc.local file the following:

To run as root:

/home/someuser/myapp/bin/nitrogen start

To run as another user:

su -c "/home/someuser/myapp/bin/nitrogen start" someuser

That will launch Nitrogen appropriately and will let you connect to the VM using bin/nitrogen attach.

My previous recommendation of using sudo is not sufficient, as it doesn't reset the environment to the user you want.

I'm using this in production on Ubuntu 14.04 and a linode VPS.

I hope that helps.