Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

My service is very basic, just an HTTP service. I just want it to restart automatically when it quits because of an error. I figured I could use runit to do this, but it seems like the runit docs mostly talk about how to convert your entire init.d to runit. I want to preserve init.d and just use runit for my one service.

I was looking at these docs.


EDIT: I think this is pointing in the right direction, I guess I just need to know how to make a service now.

share|improve this question
up vote 6 down vote accepted

Node is really simple to get running with runit. Assuming you already have runit installed in a standard directory layout, create the directory /service/node-service and place the create the file /service/node-service/run:

chpst -unobody node /path/to/your-service.js

Make that run script executable (chmod +x run) and you can test it by running sudo ./run. If you're running on Debian or Ubuntu, rather than installing runit from source it's easiest to just apt-get install runit and create the directory /etc/sv/node-service instead of /service/node-service, and then symlink /etc/sv/node-service to /etc/service/node-service. Also, if you want your service to run in the context of a user other than nobody, you should change the -u<username> parameter to reflect that.

share|improve this answer
This actually answers the question so I'm marking this as the answer. Thank you. – Bjorn Tipling Jan 17 '11 at 0:41

Take a look at forever.

share|improve this answer
That is awesome thank you! – Bjorn Tipling Jan 16 '11 at 21:29

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.