1

I have a service (small http service that listens on 0.0.0.0:8080) written in python that starts at system boot. The problem is that sometimes at server boot it starts too soon, when even IPv4 is not yet initialized (?) by kernel. Serivce failes with error (from /var/log/upstart):

socket.gaierror: [Errno -9] Address family for hostname not supported

When starting manually later it starts normally. Adding 'sleep 30' in pre-start section also helps. But I would like to know if there is a better and cleaner way to specify in upstart configuration that this service needs working ipv4. It does not need full "routing" or default gateway or even configured loopback. All it needs is the ability to bind to "any" (0.0.0.0) IPv4 address.

thor
  • 658
  • 1
  • 7
  • 18

1 Answers1

2

You can configure your job to start when the start on (started networking) event is triggered.

started This event is emitted by Upstart when a job is now running. Note that a job does not have to have an associated program or script so "running" does not necessarily imply that any additional process is executing.

user9517
  • 115,471
  • 20
  • 215
  • 297