diff --git a/jobs/carbon/spec b/jobs/carbon/spec index 4f2db7f..df0be8c 100644 --- a/jobs/carbon/spec +++ b/jobs/carbon/spec @@ -19,6 +19,9 @@ templates: config/whitelist.conf.erb: conf/whitelist.conf properties: + carbon.cache.log_to_syslog: + description: Set this to True to enable logging to syslog. + default: False carbon.cache.enable_log_rotation: description: Set this to True to enable daily log rotation. default: True diff --git a/jobs/carbon/templates/bin/carbon_ctl.erb b/jobs/carbon/templates/bin/carbon_ctl.erb index 8c2d98f..c6be4a4 100755 --- a/jobs/carbon/templates/bin/carbon_ctl.erb +++ b/jobs/carbon/templates/bin/carbon_ctl.erb @@ -29,10 +29,19 @@ case $1 in rm -f /etc/cron.daily/prune_metrics <% end %> + <% if p('carbon.cache.log_to_syslog') %> + exec chpst -u vcap:vcap python /var/vcap/packages/carbon/bin/carbon-cache.py \ + --config=/var/vcap/packages/carbon/conf/carbon.conf \ + --debug \ + start \ + 1> >(tee -a /var/vcap/sys/log/carbon/carbon.stdout.log | logger -t vcap.carbon.stdout ) \ + 2> >(tee -a /var/vcap/sys/log/carbon/carbon.stderr.log | logger -t vcap.carbon.stderr ) & + <% else %> exec chpst -u vcap:vcap python /var/vcap/packages/carbon/bin/carbon-cache.py \ --config=/var/vcap/packages/carbon/conf/carbon.conf start \ 1>> /var/vcap/sys/log/carbon/carbon_ctl.stdout.log \ 2>> /var/vcap/sys/log/carbon/carbon_ctl.stderr.log + <% end %> ;; stop) diff --git a/jobs/graphite-web/spec b/jobs/graphite-web/spec index 9045c81..03b7827 100644 --- a/jobs/graphite-web/spec +++ b/jobs/graphite-web/spec @@ -33,6 +33,9 @@ templates: config/graphite-vhost.conf.erb: conf/graphite-vhost.conf properties: + graphite-web.log_to_syslog: + description: Set this to True to enable error logging to syslog. + default: False graphite-web.secret_key: description: Set this to a long, random unique string to use as a secret key for this install. diff --git a/jobs/graphite-web/templates/config/httpd.conf.erb b/jobs/graphite-web/templates/config/httpd.conf.erb index e5411f0..8ca89f5 100644 --- a/jobs/graphite-web/templates/config/httpd.conf.erb +++ b/jobs/graphite-web/templates/config/httpd.conf.erb @@ -50,7 +50,11 @@ WSGISocketPrefix run/wsgi LogLevel warn +<% if p('graphite-web.log_to_syslog') %> +ErrorLog "|$ tee -a /var/vcap/sys/log/graphite-web/default_httpd_error.log | logger -t vcap.graphite-web" +<% else %> ErrorLog "/var/vcap/sys/log/graphite-web/default_httpd_error.log" +<% end %> LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined diff --git a/jobs/statsd/spec b/jobs/statsd/spec index b23d8ea..382b5a2 100644 --- a/jobs/statsd/spec +++ b/jobs/statsd/spec @@ -19,3 +19,6 @@ properties: statsd.carbon_cache_line_receiver_port: description: Port the carbon cache line receiver listens on. default: 2003 + statsd.log_to_syslog: + description: Set this to True to enable logging to syslog. + default: False diff --git a/jobs/statsd/templates/bin/statsd_ctl.erb b/jobs/statsd/templates/bin/statsd_ctl.erb index 47b6c4a..eac7aaa 100644 --- a/jobs/statsd/templates/bin/statsd_ctl.erb +++ b/jobs/statsd/templates/bin/statsd_ctl.erb @@ -17,6 +17,18 @@ case $1 in chown -H vcap:vcap /var/vcap/sys/log/statsd chown -H vcap:vcap /var/vcap/sys/run/statsd +<% if p('statsd.log_to_syslog') %> + start-stop-daemon --start --quiet -m \ + --pidfile /var/vcap/sys/run/statsd/statsd.pid \ + --startas /var/vcap/packages/node/bin/node \ + --chuid vcap:vcap \ + --background \ + --no-close \ + --chdir /var/vcap/packages/statsd \ + -- /var/vcap/packages/statsd/stats.js /var/vcap/packages/statsd/localConfig.js \ + 1> >(tee -a /var/vcap/sys/log/statsd/statsd.stdout.log | logger -t vcap.statsd.stdout ) \ + 2> >(tee -a /var/vcap/sys/log/statsd/statsd.stderr.log | logger -t vcap.statsd.stderr ) +<% else %> start-stop-daemon --start --quiet -m \ --pidfile /var/vcap/sys/run/statsd/statsd.pid \ --startas /var/vcap/packages/node/bin/node \ @@ -27,6 +39,7 @@ case $1 in -- /var/vcap/packages/statsd/stats.js /var/vcap/packages/statsd/localConfig.js \ 1>> /var/vcap/sys/log/statsd/statsd_ctl.stdout.log \ 2>> /var/vcap/sys/log/statsd/statsd_ctl.stderr.log +<% end %> ;; stop)