1

I am using Ubuntu 14.04.3 on a server that runs a bunch of homemade web applications. I want each application to launch soon after the system launches—specifically, as soon as Postgresql is running—and then run until the system is shut down.

Right now I’m doing this with GNU Screen: I run each application in its own terminal “window”. This is straightforward, and it makes it easy to see any error output that gets generated, but it feels amateurish and I have to do it by hand each time the system is restarted.

I looked into writing Upstart configuration scripts for each application but I’d have to choose one of these unappealing options:

  • System jobs are run by root and require that configuration files be installed in a system path.
  • User jobs seem like what I want but they’re deprecated in recent versions of Upstart and apparently not even supported in Ubuntu.
  • Session jobs are extremely finicky to set up if you’re running a server.

Apart from all of this, Upstart has already started to be replaced by systemd in recent versions of Ubuntu.

What is the recommended way to start a task such as I am describing? Should I bite the bullet and use an Upstart system job, or is there an easier way?

1

As long as I'm following Ask Ubuntu, I never saw any one using user & session upstart jobs. This is the first time I heard about their existence.

  • User jobs were deprecated with upstart v1.7, Ubuntu 14.04 comes with v1.12
  • Session jobs were made for other purpose mainly user session. It seems not right to start a user init session in a server just to run those daemons.

Better to stick with system jobs, use su or sudo to run them as a different user and may be cleaner if you use setuid and setgid, or exec start-stop-daemon --start -c <myuser> --exec <command> see Run a Job as a Different User

BTW, You may use start on started postgresql & stop on stopping postgresql as you services are depending on postgresql. So they are started after it get started then stopped before it get stopped. See similar case here How can I make sure one Upstart job stops before another Upstart job stops?

To monitor for error, you could use its logging feature.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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