I wrote a web application with Go and setup it to be launched by upstart during system boot. However, it failed to start after reboot. Checked dmsg and found out it cannot connect to PostgreSQL that was launched by SysV init script rather than upstart.

One possible solution is to also lunch PostgreSQL with upstart and start my app after PostgreSQL is started as suggested by 6.33.2 Start depends on another service:

start on started postgresql

Another solution is to add respawn delay so that my app can be respawn after PostgreSQL:

respawn
respawn limit 10 200
post-stop exec sleep 10

I chose the 2nd quick-and-dirty way until I need to do it again for more apps.