Well there are two options
1) easy way Cron
create an entry in your crobtab ( usually crontab -e will open the editor
for you)
<crontab -e> ------------------ editor
@reboot $DEBUG=myapp npm start
better practice would be create a script say under /usr/src/scripts ( chmod
it to 755 or similar ) and call the script @reboot. such as
<crontab -e> ------------------ editor
@reboot /usr/src/script/myscript.sh >> /var/log/myscript.log
Like that you actually have your console outputs saved in a log file as
well.
2) The more complex one is create a daemon script ( varies slightly across
distributions.
#!/bin/sh
#
# /etc/init.d/mysystem
# Subsystem file for "MySystem" server
#
# chkconfig: 2345 95 05 [image: (1)]
# description: MySystem server daemon
#
# processname: MySystem
# config: /etc/MySystem/mySystem.conf
# config: /etc/sysconfig/mySystem
# pidfile: /var/run/MySystem.pid
# source function library
. /etc/rc.d/init.d/functions
# pull in sysconfig settings
[ -f /etc/sysconfig/mySystem ] && . /etc/sysconfig/mySystem [image: (2)]
RETVAL=0
prog="MySystem"
.
. [image: (3)]
.
start() { [image: (4)]
echo -n $"Starting $prog:"
.
. [image: (5)]
.
RETVAL=$?
[ "$RETVAL" = 0 ] && touch /var/lock/subsys/$prog
echo
}
stop() { [image: (6)]
echo -n $"Stopping $prog:"
.
. [image: (7)]
.
killproc $prog -TERM
RETVAL=$?
[ "$RETVAL" = 0 ] && rm -f /var/lock/subsys/$prog
echo
}
reload() { [image: (8)]
echo -n $"Reloading $prog:"
killproc $prog -HUP
RETVAL=$?
echo
}
case "$1" in [image: (9)]
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
reload)
reload
;;
condrestart)
if [ -f /var/lock/subsys/$prog ] ; then
stop
# avoid race
sleep 3
start
fi
;;
status)
status $prog
RETVAL=$?
;;
*) [image: (10)]
echo $"Usage: $0 {start|stop|restart|reload|condrestart|status}"
RETVAL=1
esac
exit $RETVAL
< quoted from http://www.tldp.org/HOWTO/HighQuality-Apps-HOWTO/boot.html >
I use both methods depending on the mode of operation and the level of
control I want to give users on the box.
1st is adequate second is proper.
david.
On Saturday, August 29, 2015 at 4:41:48 AM UTC+2, Uomo di Carbone wrote:
>
> I am currently running express on an Rpi at: http://111001.cc
> Is there a way to make it part of rc ? sudo update-rc.d vsftpd defaults
> I would like to start the service and have is run automatically on reboot
> like ftp apache nginx ssh ...
> rather than issue a
>
> $DEBUG=myapp npm start
>
> Thanks you
>
>
--
Job board: http://jobs.nodejs.org/
New group rules:
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules:
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 unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/nodejs/75cfde40-2009-47b9-a3ca-33776de69a5d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.