Skip to content

Commit

Permalink
Merge pull request #179 from darron/move-log-file
Browse files Browse the repository at this point in the history
Be able to move the log file with an attribute.
  • Loading branch information
johnbellone committed May 29, 2015
2 parents efb204d + 51232b4 commit 7c7a99e
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
default['consul']['bootstrap_expect'] = 3
default['consul']['data_dir'] = '/var/lib/consul'
default['consul']['config_dir'] = '/etc/consul.d'
default['consul']['logfile'] = '/var/log/consul.log'
case node['platform_family']
when 'debian'
default['consul']['etc_config_dir'] = '/etc/default/consul'
Expand Down
3 changes: 3 additions & 0 deletions recipes/_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,9 @@
template init_file do
source init_tmpl
mode init_mode
variables(
consul_logfile: node['consul']['logfile']
)
notifies :restart, 'service[consul]', :immediately
end

Expand Down
2 changes: 1 addition & 1 deletion templates/default/consul-init.erb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ CMD="<%= Chef::Consul.active_binary(node) %> agent -config-dir <%= node['consul'
NAME="consul"

PIDFILE="/var/run/$NAME.pid"
LOGFILE="/var/log/$NAME.log"
LOGFILE="<%= @consul_logfile %>"

get_pid() {
cat "$PIDFILE"
Expand Down
2 changes: 1 addition & 1 deletion templates/default/consul.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ script
fi
export GOMAXPROCS=${GOMAXPROCS}
CMD="<%= Chef::Consul.active_binary(node) %> agent -config-dir <%= node['consul']['config_dir'] %>"
LOGFILE="/var/log/consul.log"
LOGFILE="<%= @consul_logfile %>"
exec $CMD >> "$LOGFILE"
end script

Expand Down

0 comments on commit 7c7a99e

Please sign in to comment.