Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?

share|improve this question

4 Answers 4

up vote 2 down vote accepted

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:

script.sh restart
share|improve this answer
  1. Give them a normal user.
  2. Put your desired command in their path.
  3. Set the SETUID flag for your executable.

    # chmod u+s [your executable file for service restart]

share|improve this answer

Configure 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.

share|improve this answer

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:

  1. Monit: http://mmonit.com/monit/
  2. Upstart: http://upstart.ubuntu.com/
  3. Daemontools: http://cr.yp.to/daemontools.html
  4. Launchtool: http://people.debian.org/~enrico/launchtool.html

Luckily, there is a node.js specific app called 'forever' that will accomplish this for you easily. Here is a very helpful tutorial on how to use it.

The quick way is:

npm install forever -g
forever start app.js
share|improve this answer
    
I do use forever. The problem is that the service I want to give access to is not usually running and needs to be started while I am gone. –  Mike Wills Jul 10 '12 at 16:16
    
In this case, I would have suggested setting up a cron job to start it once via forever before you will be leaving ;-) –  TrinitronX Jul 10 '12 at 18:18
    
It is a replacement bot for a Turntable.fm room. The other is getting packed in a box for a week. Timing isn't something I control. I am using the answer for now and will be shutting it down when I get back. –  Mike Wills Jul 10 '12 at 18:21
    
Perhaps in this case designating a co-pilot is best. Good luck with the bot ;-) –  TrinitronX Jul 10 '12 at 21:18

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.