From 0430a6b0d5a8054da261911a488963ef2d7766ac Mon Sep 17 00:00:00 2001 From: richerd Date: Tue, 29 Jul 2014 13:48:16 -0400 Subject: [PATCH 1/3] Add support for centos 6.x --- metadata.rb | 1 + templates/centos-6/upstart.conf.erb | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 templates/centos-6/upstart.conf.erb diff --git a/metadata.rb b/metadata.rb index a1956a6..a5dff97 100644 --- a/metadata.rb +++ b/metadata.rb @@ -11,3 +11,4 @@ depends 'nodejs', '>= 0.5.2' supports 'ubuntu' +supports 'centos', '~> 6.0' diff --git a/templates/centos-6/upstart.conf.erb b/templates/centos-6/upstart.conf.erb new file mode 100644 index 0000000..1c0a38c --- /dev/null +++ b/templates/centos-6/upstart.conf.erb @@ -0,0 +1,25 @@ +# statsd - Network daemon for aggregating statistics +# +# This is a network service that receives metric data via UDP from other +# applications. It aggregates this data and flushes it to a storage backend +# (typically Graphite) at regular intervals. +# +description "Network daemon for aggregating statistics" +author "Librato" + +start on (local-filesystems and net-device-up IFACE!=lo) + +respawn +respawn limit 10 5 + +chdir <%= node['statsd']['path'] %> + +pre-start script + NODE_BIN=$(which nodejs || which node) + [ -n $NODE_BIN ] || { stop; exit 0; } +end script + +script + NODE_BIN=$(which nodejs || which node) + su -s /bin/sh -c 'exec "$0" "$@"' statsd -- $NODE_BIN stats.js <%= node['statsd']['config_dir'] %>/config.js 2>&1 >> <%= node['statsd']['log_file'] %> +end script From 6f9b281d90c6dbf95d04d5b1931012b132e1879f Mon Sep 17 00:00:00 2001 From: richerd Date: Tue, 29 Jul 2014 16:07:17 -0400 Subject: [PATCH 2/3] No longer used hard coded statsd user --- templates/centos-6/upstart.conf.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/centos-6/upstart.conf.erb b/templates/centos-6/upstart.conf.erb index 1c0a38c..34e9ba8 100644 --- a/templates/centos-6/upstart.conf.erb +++ b/templates/centos-6/upstart.conf.erb @@ -21,5 +21,5 @@ end script script NODE_BIN=$(which nodejs || which node) - su -s /bin/sh -c 'exec "$0" "$@"' statsd -- $NODE_BIN stats.js <%= node['statsd']['config_dir'] %>/config.js 2>&1 >> <%= node['statsd']['log_file'] %> + su -s /bin/sh -c 'exec "$0" "$@"' <%= node['statsd']['user'] %> -- $NODE_BIN stats.js <%= node['statsd']['config_dir'] %>/config.js 2>&1 >> <%= node['statsd']['log_file'] %> end script From b5b34b927d8398be2a0daa7b9a9b8f9a5078adee Mon Sep 17 00:00:00 2001 From: richerd Date: Wed, 30 Jul 2014 21:19:13 -0400 Subject: [PATCH 3/3] Add centos-6.5 to test configuration In serverspec, force Debian instead of DetectOS to properly detect statsd service for upstart on CentOS 6. --- .kitchen.yml | 1 + test/integration/default/serverspec/default_spec.rb | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.kitchen.yml b/.kitchen.yml index 0d03362..69e82ae 100644 --- a/.kitchen.yml +++ b/.kitchen.yml @@ -7,6 +7,7 @@ provisioner: platforms: - name: ubuntu-12.04 + - name: centos-6.5 suites: - name: default diff --git a/test/integration/default/serverspec/default_spec.rb b/test/integration/default/serverspec/default_spec.rb index 17f23ca..794a3b5 100644 --- a/test/integration/default/serverspec/default_spec.rb +++ b/test/integration/default/serverspec/default_spec.rb @@ -1,7 +1,8 @@ require 'serverspec' include Serverspec::Helper::Exec -include Serverspec::Helper::DetectOS +# Force Debian to properly detect statsd service for upstart on CentOS 6. +include Serverspec::Helper::Debian RSpec.configure do |c| c.before :all do