description "Consul agent" start on started network stop on runlevel [!2345] respawn # This is to avoid Upstart re-spawning the process upon `consul leave` normal exit 0 INT script if [ -f "/etc/service/consul/flags" ]; then . /etc/service/consul/flags fi # Make sure to use all our CPUs, because Consul can block a scheduler thread export GOMAXPROCS=`nproc` # Get the public IP BIND=`ifconfig eth0 | grep "inet addr" | awk '{ print substr($2,6) }'` SERVER_JOIN=$(sed 's/ip/ -retry-join=ip/' /etc/service/consul/servers.conf) exec /usr/local/bin/consul agent \ -config-dir="/etc/consul.d" \ -bind=$BIND \ ${CONSUL_FLAGS} \ ${SERVER_JOIN} \ >>/var/log/consul.log 2>&1 end script