I am going to be in the middle of nowhere for 10 days later this summer. I have a service that needs to stay running and if there is a problem when I am gone, I want to give one or two trusted people access to be able to restart that service. The service is a node.js application and even though they are very technical, I want it to be as simple as running a script via SSH (or a better option if there is one). What would be the best approach to accomplish this?
Just setup additional account for trusted people. Allow for this account only start/stop/restart operation for node.js application. After all, you could manage your app with following example script:
#!/bin/bash command=$1 ssh user@host "your-app $command"
After that run it like this:
To avoid the need for a second person altogether, you should probably be using a watchdog type software to keep the service up. There are many different tools used on Linux to do this, such as:
- Monit: http://mmonit.com/monit/
- Upstart: http://upstart.ubuntu.com/
- Daemontools: http://cr.yp.to/daemontools.html
- Launchtool: http://people.debian.org/~enrico/launchtool.html
The quick way is:
npm install forever -g forever start app.js
sudo so these two users can execute the necessary commands to stop/star/whatever the service.
The easiest off course is if you have an init script that does all the required things. Then all you need is to grant these users
/sbin/service <servicename> ... or similar depending on your distro.
That way you don't have to change anything to your setup and you're certain everything will be started with all the correct parameters and settings and such.