# Consul Agent (Upstart unit)
description "Consul Agent"
start on (local-filesystems and net-device-up IFACE!=lo)
stop on runlevel [06]

env CONSUL=<%= scope.lookupvar('consul::bin_dir') %>/consul
env CONFIG=<%= scope.lookupvar('consul::config_dir') %>

setuid <%= scope.lookupvar('consul::user') %>
setgid <%= scope.lookupvar('consul::group') %>


script
    # read settings like GOMAXPROCS from "/etc/default/consul", if available.
    [ -e /etc/default/consul ] && . /etc/default/consul

    export GOMAXPROCS=${GOMAXPROCS:-2}
    exec $CONSUL agent -config-dir $CONFIG <%= scope.lookupvar('consul::extra_options') %>

end script

respawn
respawn limit 10 10
kill timeout 10

# Consul Agent (Upstart unit)
description "Consul Agent"
start on (local-filesystems and net-device-up IFACE!=lo)
stop on runlevel [06]

env CONSUL=<%= scope.lookupvar('consul::bin_dir') %>/consul
env CONFIG=<%= scope.lookupvar('consul::config_dir') %>


script
    # read settings like GOMAXPROCS from "/etc/default/consul", if available.
    [ -e /etc/default/consul ] && . /etc/default/consul

    export GOMAXPROCS=${GOMAXPROCS:-2}
    exec sudo -u <%= scope.lookupvar('consul::user') %> -g <%= scope.lookupvar('consul::group') %> $CONSUL agent -config-dir $CONFIG <%= scope.lookupvar('consul::extra_options') %>
end script

respawn
respawn limit 10 10
kill timeout 10

Revert setuid/setgid Upstart changes which are incompatible with Ubuntu 10.04
Revert setuid/setgid Upstart changes which are incompatible with Ubuntu 10.04

Use `exec sudo ...` instead of Upstart's setuid/setgid directives
as those directives are not supported on older versions on Ubuntu.
