Upstart and init.d priority

I use foreman to run my node.js applications on the production servers (ubuntu server 12). Foreman has a great tool to create scripts for upstart.

The problem is that when I reboot a server, my application (managed by foreman) is launched before redis-server and I've to build some tricks in order to wait for a valid connection.

The ideal solution will be to start redis-server earlier, and hen the node application when all is started.

Boot configuration :

  • redis-server is launched by /etc/init.d/redis-server and is /etc/rc2.d/S20redis-server
  • my node application is started with /etc/init/stocks-streamer*.conf files

My question is : how would you change the boot order of my node application? I want to wait for redis-server before my application starts but when I do this, it doesn't start :

start on (started redis-server)

I imagine that it's because no events are sent from init.d scripts to upstart but perhaps there is a way I don't know ?

Thanks by advance for your help !

Perhaps you should have redis be started by foreman instead, so you can better control all the dependencies of your app.

Or make sure foreman start much later than redis (make sure foreman's link in /etc/rc2.d is listed later than S20*.

One more alternative: have redis server also be started by upstart, this is likely going to help upstart manage the dependencies.

There are explanations on how to do this here: https://gist.github.com/bdotdub/714533

And I suggest using "Start must precede another service" instead (http://upstart.ubuntu.com/cookbook/#start-must-precede-another-service) so that redis gets started when you start your own service.