Super User is a question and answer site for computer enthusiasts and power users. 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

I am trying to turn my node.js server into a service.

I have tried a few different ways, but have not had any success yet. Is there anyone who is able to help me out with this?

Thanks!

share|improve this question
    
Could you edit your question to show what you have tried and (if possible) whether there was even a partial success? This would help as we would then not be retrying the same solutions you have already tried. – Mokubai Jun 27 '11 at 22:03

Perhaps you could do something like the following. Just replace below with your script, and place the script in /etc/init.d

#!/bin/sh
#
# myservice     This shell script takes care of starting and stopping
#               the <myservice>
#

# Source function library
. /etc/rc.d/init.d/functions


# Do preliminary checks here, if any
#### START of preliminary checks #########


##### END of preliminary checks #######


# Handle manual control parameters like start, stop, status, restart, etc.

case "$1" in
  start)
    # Start daemons.

    echo -n $"Starting <myservice> daemon: "
    echo
    daemon <myservice>
    echo
    ;;

  stop)
    # Stop daemons.
    echo -n $"Shutting down <myservice>: "
    killproc <myservice>
    echo

    # Do clean-up works here like removing pid files from /var/run, etc.
    ;;
  status)
    status <myservice>

    ;;
  restart)
    $0 stop
    $0 start
    ;;

  *)
    echo $"Usage: $0 {start|stop|status|restart}"
    exit 1
esac

exit 0

Original source, here.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .