This is incorrect, screen allows you to partition a console but will not guarantee your service is automatically started at boot time or restarted if it fail.
As Ryan said, it depends what OS are you targeting. The way you do services in ubuntu is with upstart. You put an script under /etc/init/your-app.conf :
description "your-app"
author "you"
setuid some-user
start on (local-filesystems and net-device-up IFACE=eth0)
stop on shutdown
respawn
respawn limit 15 5
script
exec >>/var/log/$UPSTART_JOB.log 2>&1
echo starting\ $UPSTART_JOB\ `date`
cd /usr/local/lib/node_modules/your-app
NODE_ENV=production CONFIG_FILE="/etc/your-app.json" npm start
end script
You can store your application in any path, usually /opt, the one i used for this example assumes you install your-app as a global node module.
This will redirect stdout and stderr to /var/log/your-app.log, make sure you create a logrotate rule.
It also assumes you have some sort of config file in /etc/your-app.json.
Then the service will be started when booting the OS, and restarted if it fails.
You can also start/stop/restart manually as follows:
service your-app stop/start/restart
If you symlink /etc/init/your-app.conf to /etc/init.d/your-app, you will get also tab-completion in bash when writing service yo.
Every SO has a different way of doing this :
initng
launchd
upstart
Service Management Facility
systemd
OpenRC
runit
daemontools
to name a few.
regards
You can use screen . Here is a tutorial : how-to-install-and-use-screen-on-an-ubuntu-cloud-server
--
--
Job Board: http://jobs.nodejs.org/
Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nod...@googlegroups.com
To unsubscribe from this group, send email to
nodejs+un...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en
---
You received this message because you are subscribed to the Google Groups "nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
I use forever and have not had any issues.
--
#!/bin/sh
#
# chkconfig: 235 90 10
# description: Starts YOUR_SERVICE to control application.
# source function library
. /etc/rc.d/init.d/functions
NAME=YOUR_SERVICE
DAEMONDIR="/usr/bin"
DAEMON="/usr/bin/forever"
DAEMON_ARGS="-l /var/log/YOUR_SERVICE --append --silent --spinSleepTime 1000 --minUptime 1000"
APPDIR="/usr/lib/node_modules/Your_APP"
APP_ARGS=""
# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 1
fail()
{
failure
echo
echo $1
}
#
# Function that starts the daemon/service
#
start()
{
echo -n $"Starting $NAME: "
$DAEMON start $DAEMON_ARGS $APPDIR $APP_ARGS
RETVAL=$?
[ $RETVAL -eq 0 ] && success || failure
echo
return $RETVAL
}
#
# Function that stops the daemon/service THIS IS A LITTLE BRUTE FORCE but it works for me.
#
stop()
{
echo -n $"Signaling $NAME to stop: "
$DAEMON stopall
RETVAL=$?
[ $RETVAL -eq 0 ] && success || failure
echo
return $RETVAL
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
RETVAL=$?
;;
*)
echo "Usage: $NAME {start|stop|restart}"
exit 1
;;
esac
exit $RETVAL
You received this message because you are subscribed to a topic in the Google Groups "nodejs" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/nodejs/S8ujZwF6zXQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to nodejs+un...@googlegroups.com.