So I’ve had to play with upstart because that’s how packaged gogs handles the init script of gogs…

Anyways what’s awesome is that if you want to run mysql on the same box, gogs will try and start, then it will try and talk to mysql, and after a random amount of time it will just give up on life and die in a fire… which is really annoying and sad.

So what did I have to do? A terrible hack like this:

ubuntu@ip-172-31-42-43:~$ cat /etc/init/gogs-web-1.conf
start on starting gogs-web
stop on stopping gogs-web
respawn

script
  until nc -z localhost 3306; do
    echo "waiting for port 3306 to open"
    sleep 1
  done
  env PORT=6000
  exec gogs run web >> /var/log/gogs/web-1.log 2>&1
end script

Which I basically ripped from here: http://eosrei.net/articles/2014/11/waiting-processportservice-custom-upstart-service

I hate upstart.