I'm trying to enable my nodejs server to run at boot and respawn if it crashes. I'm only familiar with systemd and pm2 for setting up services and I'm getting hung up with busybox init.
I see tinycore provides the command start-stop-daemon. Is it possible to have this create the daemon for my nodejs server automatically so that if it crashes it reboots? I'm trying it just in SSH and while I can get it to start the process in the background, if I pkill node it doesnt reboot and its not making a PID file so trying to run it multiple times starts up multiple processes.
start-stop-daemon --start --exec ./run.sh --make-pidfile --pidfile /run/server.pid -- --daemon
I've also seen that I could put it in the /etc/inittab file:
::respawn:/home/tc/node/run.sh
run.shnode ./server.js
I'd like to create an init.d script to stop/start/restart the process, but I'm unsure how that works if I put the process in the inittab file. If I also then called stop, wouldnt inittab just auto respawn it? How do I get these to all work together?
I also tried installing pm2, but since it needs to be installed globally I'm having an issue with it trying to install into the readonly partition.