1description "Consul agent"
2
3start on runlevel [2345]
4stop on runlevel [!2345]
5
6respawn
7
8script
9  if [ -f "/etc/service/consul" ]; then
10    . /etc/service/consul
11  fi
12
13  # Make sure to use all our CPUs, because Consul can block a scheduler thread
14  export GOMAXPROCS=`nproc`
15
16  # Get the public IP
17  BIND=`ifconfig eth0 | grep "inet addr" | awk '{ print substr($2,6) }'`
18
19  exec /usr/local/bin/consul agent \
20    -config-dir="/etc/consul.d" \
21    -bind=$BIND \
22    ${CONSUL_FLAGS} \
23    >>/var/log/consul.log 2>&1
24end script
25