0

What is the way to keep some process running (web server, database and so on) in background, and be sure that in case of system reboot it will start immediately again?

I'd like to have this feature for not-provisioned user (without sudo access), so upstart may be problematic here. Moreover it would be perfect to have ansible playbook or chef recipe for that and automated deployment so that each time process will be restarted.

I know there's runit, supervisord and so on, but many of them does not have simple setup and are not available without sudo access.

Falcon Momot
  • 25,244
  • 15
  • 63
  • 92
Kamil Lelonek
  • 113
  • 1
  • 7
  • 1
    It sounds like your *real* problem is that you have a sysadmin you don't trust with root. That's a people problem. Maybe you have customers you don't trust not to trash each other's configs. Virtual machines would solve that. Let us know the real problem and you will get better solutions. – Ladadadada Oct 04 '14 at 10:20
  • I'm building a system with many small applications and I want to restrict (or isolate) access for each application so that they cannot mess witch each other and with root too. – Kamil Lelonek Oct 04 '14 at 12:01
  • 3
    Go look into Linux containers. – Michael Hampton Oct 04 '14 at 14:24
  • I'm reading about Docker right now, it seems promising. – Kamil Lelonek Oct 04 '14 at 14:54
  • "I want to restrict (or isolate)"... what are you possibly running that would not allow you to do this? Or better yet, why on Earth is your installation running a bunch of stuff as root when it's been standard practice to drop privs for over a decade now? This question scares me. – Avery Payne Dec 17 '14 at 00:54

1 Answers1

0

If your cron daemon supports @reboot, you can create a crontab with this content:

@reboot /command/to/start/service

Alternatively you could add a command to /etc/rc.local which will su to the proper user and run the command. For example:

su - someuser -c bin/rc.sh &
kasperd
  • 30,455
  • 17
  • 76
  • 124
  • This generally works (in the past, I used a crontab entry starting every 5 minutes to check the existence of the service, as I didn't know about @reboot...). However, if your service needs any privileges you don't have as a standard user (e.g. the web server listening on port 80), you simply wont be able to start it, whether with a crontab or just from a terminal. – Ale Oct 13 '14 at 19:46