6

I have a particular service (in this case OpenFire) that runs at startup. When it starts, it attempts to connect to a database at a given hostname. At startup time it fails to connect to that database because it cannot find the host in DNS.

My best guess is that this service is executing on startup before networking has initialized and DNS servers have been obtained from DHCP. Is there any way to specify startup service dependencies that must be met before executing the /etc/init.d/ script?

Marco Ceppi
  • 48,827
roktechie
  • 163

3 Answers3

3

Forget about upstart. There are much easier ways to do this. Put a script that launches Openfire here:

 /etc/network/if-up.d/

If openfire has to run as your user, so something like:

#!/bin/sh
su -c "openfire" myUserName

Make sure you mark it as executable:

sudo chmod +x /etc/network/if-up.d/openfire

Likewise you can close openfire, when you loose your network connection, by putting a script in /etc/network/if-down.d/ that kills it:

#!/bin/sh
killall openfire
Ralf
  • 2,226
1

You could look in /etc/rc0.d for the service; it will have S##[name], for example, S35networking.

So if you make it say S36openfire then it should load just after networking. Or make the number 99 (instead of 36) and it will load last, giving the network time to do its thing.

Hope that'll do the trick for you.

Zanna
  • 72,312
-1

if you don't configure your network using NetworkManager, you can try to configure your upstart conf to depend on networking:

start on starting networking

or

start on starting network-interface

I don't know how it interacts with NetworkingManager, perhaps NM triggers some events which are detectable through upstart.

mkm
  • 3,239