diff --git a/CHANGELOG.md b/CHANGELOG.md index 71cef524..cd39821c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## 2016-04-11 - 6.0.2 (Bugfix release) + +#### Bugfixes: + +- (debfe5d) remove parameter `gr_pid_dir` and use `gr_storage_dir` instead. +- RedHat init scripts use correct `gr_base_dir` for graphite. + ## 2016-04-01 - 6.0.1 (Bugfix release) #### Features: diff --git a/Gemfile b/Gemfile index c709f5b0..fef97e45 100644 --- a/Gemfile +++ b/Gemfile @@ -11,18 +11,14 @@ def location_for(place, version = nil) end gem 'puppet', *location_for(ENV['PUPPET_GEM_VERSION'] || '~> 4') -gem 'facter', '>= 2.0' +gem 'facter', *location_for(ENV['FACTER_GEM_VERSION'] || '~> 2') gem 'puppetlabs_spec_helper', '>= 0.1.0', :require => false gem 'puppet-lint', '>= 0.3.2', :require => false gem 'rspec-puppet', '>= 2.3.2', :require => false +gem 'rspec-puppet-facts', :require => false gem 'metadata-json-lint', :require => false gem 'rake', '< 11.0.0' # rubi <1.9 versus rake 11.0.0 workaround -if ENV['COVERAGE'] == 'yes' - gem 'simplecov', :require => false - gem 'coveralls', :require => false -end - if File.exists? "#{__FILE__}.local" eval(File.read("#{__FILE__}.local"), binding) end diff --git a/README.md b/README.md index cf92d98b..67ef9715 100644 --- a/README.md +++ b/README.md @@ -373,7 +373,7 @@ Default is '/opt/graphite'. Set base install location of Graphite. This forms th #####`gr_storage_dir` -Default is '${gr_base_dir}/storage'. Set location of base storage files. When not installing using pip a typical location for this may be '/opt/carbon'. +Default is '${gr_base_dir}/storage'. Set location of base storage files. When not installing using pip a typical location for this may be '/opt/carbon'. This dir is also used as pid dir on RedHat. #####`gr_local_data_dir` diff --git a/manifests/config.pp b/manifests/config.pp index 91f71346..1588ea4f 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -109,7 +109,6 @@ $::graphite::rrd_dir_REAL, $::graphite::whitelists_dir_REAL, $::graphite::graphiteweb_log_dir_REAL, - $::graphite::gr_pid_dir, "${::graphite::base_dir_REAL}/bin"]: ensure => directory, group => $gr_web_group_REAL, diff --git a/manifests/config_apache.pp b/manifests/config_apache.pp index 11922fca..c940a566 100644 --- a/manifests/config_apache.pp +++ b/manifests/config_apache.pp @@ -91,6 +91,8 @@ hasstatus => true; } + + # Deploy configfiles file { "${::graphite::params::apache_dir}/ports.conf": @@ -104,6 +106,7 @@ Package[$::graphite::params::apache_wsgi_pkg], ], notify => Service[$::graphite::params::apache_service_name]; + "${::graphite::params::apacheconf_dir}/graphite.conf": ensure => file, content => template($::graphite::gr_apache_conf_template), @@ -111,7 +114,7 @@ mode => '0644', owner => $::graphite::config::gr_web_user_REAL, require => [ - File[$::graphite::gr_storage_dir], + File[$::graphite::storage_dir_REAL], File["${::graphite::params::apache_dir}/ports.conf"], ], notify => Service[$::graphite::params::apache_service_name]; diff --git a/manifests/init.pp b/manifests/init.pp index ed431bfd..578404a5 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -671,7 +671,6 @@ $gr_graphiteweb_webapp_dir = undef, $gr_graphiteweb_storage_dir = '/var/lib/graphite-web', $gr_graphiteweb_install_lib_dir = undef, - $gr_pid_dir = '/var/run', $gr_apache_logdir = '/var/log/httpd/graphite-web', $gunicorn_arg_timeout = 30, $gunicorn_bind = 'unix:/var/run/graphite.sock', diff --git a/metadata.json b/metadata.json index 861b8425..1d6d28f8 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "dwerder-graphite", - "version": "6.0.1", + "version": "6.0.2", "source": "https://github.com/echocat/puppet-graphite.git", "author": "Daniel Werdermann", "license": "Apache-2.0", @@ -64,6 +64,5 @@ "name": "puppet", "version_requirement": ">= 3.0.0 < 5.0.0" } - ], - "description": "Graphite module" + ] } diff --git a/spec/classes/config_spec.rb b/spec/classes/config_spec.rb index 008d166c..fe50e416 100644 --- a/spec/classes/config_spec.rb +++ b/spec/classes/config_spec.rb @@ -2,34 +2,6 @@ describe 'graphite::config', :type => 'class' do - shared_context 'Unsupported OS' do - it { is_expected.to raise_error(Puppet::Error,/unsupported os,.+\./ )} - end - - shared_context 'Debian unsupported platforms' do - it { is_expected.to raise_error(Puppet::Error,/Unsupported Debian release/) } - end - - shared_context 'RedHat unsupported platforms' do - it { is_expected.to raise_error(Puppet::Error,/Unsupported RedHat release/) } - end - - shared_context 'supported platforms' do - it { is_expected.to contain_class('graphite::params') } - it { is_expected.to contain_exec('Initial django db creation') } - it { is_expected.to contain_class('graphite::config_apache') } - - # cron check - it { is_expected.to contain_file('/opt/graphite/bin/carbon-logrotate.sh').with({ - 'ensure' => 'file', 'mode' => '0544', 'content' => /^CARBON_LOGS_PATH="\/opt\/graphite\/storage\/log"$/ }) } - it { is_expected.to contain_cron('Rotate carbon logs').with({ - 'command' => '/opt/graphite/bin/carbon-logrotate.sh', - 'hour' => '3', - 'minute' => '15', - 'require' => 'File[/opt/graphite/bin/carbon-logrotate.sh]', - 'user' => 'root',}) } - end - shared_context 'RedHat supported platforms' do it { is_expected.to contain_file('/opt/graphite/storage/whisper').with({ 'ensure' => 'directory', 'owner' => 'apache', 'group' => 'apache', 'mode' => '0755', }) } @@ -44,13 +16,32 @@ 'ensure' => 'file', 'owner' => 'apache', 'group' => 'apache', 'mode' => '0644' }).that_requires('Package[httpd]') } it { is_expected.to contain_file('/opt/graphite/webapp/graphite/graphite_wsgi.py').with({ 'ensure' => 'link', 'target' => '/opt/graphite/conf/graphite_wsgi.py', 'require' => 'File[/opt/graphite/conf/graphite_wsgi.py]' }) } + it { is_expected.to contain_service('carbon-cache').with({ + 'ensure' => 'running', + 'enable' => 'true', + 'hasrestart' => 'true', + 'hasstatus' => 'true', + 'provider' => 'redhat', + 'require' => 'File[/etc/init.d/carbon-cache]' }) } end shared_context 'RedHat 6 platforms' do + it { is_expected.to contain_file('/etc/init.d/carbon-cache').with({ + 'ensure' => 'file', + 'content' => /^GRAPHITE_DIR="\/opt\/graphite"$/, + 'mode' => '0750', + 'require' => 'File[/opt/graphite/conf/carbon.conf]', + 'notify' => [] }) } end shared_context 'RedHat 7 platforms' do it { is_expected.to contain_exec('graphite-reload-systemd') } + it { is_expected.to contain_file('/etc/init.d/carbon-cache').with({ + 'ensure' => 'file', + 'content' => /^GRAPHITE_DIR="\/opt\/graphite"$/, + 'mode' => '0750', + 'require' => 'File[/opt/graphite/conf/carbon.conf]', + 'notify' => /graphite-reload-systemd/ }) } end shared_context 'Debian supported platforms' do @@ -67,50 +58,69 @@ 'ensure' => 'file', 'owner' => 'www-data', 'group' => 'www-data', 'mode' => '0644' }).that_requires('Package[apache2]') } it { is_expected.to contain_file('/opt/graphite/webapp/graphite/graphite_wsgi.py').with({ 'ensure' => 'link', 'target' => '/opt/graphite/conf/graphite_wsgi.py', 'require' => 'File[/opt/graphite/conf/graphite_wsgi.py]' }) } + it { is_expected.to contain_service('carbon-cache').only_with({ + 'ensure' => 'running', + 'enable' => 'true', + 'hasrestart' => 'true', + 'hasstatus' => 'true', + 'provider' => nil, + 'require' => 'File[/etc/init.d/carbon-cache]' }) } + it { is_expected.to contain_file('/etc/init.d/carbon-cache').with({ + 'ensure' => 'file', + 'content' => /^GRAPHITE_DIR="\/opt\/graphite"$/, + 'mode' => '0750', + 'require' => 'File[/opt/graphite/conf/carbon.conf]', + 'notify' => [] }) } + end + + + context 'Unsupported OS' do + let(:facts) {{ :osfamily => 'unsupported', :operatingsystem => 'UnknownOS' }} + it { is_expected.to raise_error(Puppet::Error,/unsupported os,.+\./ )} end - # Loop through various contexts - [ { :osfamily => 'Debian', :lsbdistcodename => 'capybara', :operatingsystem => 'Debian' }, - { :osfamily => 'Debian', :lsbdistcodename => 'squeeze', :operatingsystem => 'Debian' }, - { :osfamily => 'Debian', :lsbdistcodename => 'trusty', :operatingsystem => 'Debian' }, - { :osfamily => 'FreeBSD', :operatingsystemrelease => '8.4-RELEASE-p27', :operatingsystem => 'FreeBSD' }, - { :osfamily => 'RedHat', :operatingsystemrelease => '5.0', :operatingsystem => 'CentOS' }, - { :osfamily => 'RedHat', :operatingsystemrelease => '6.6', :operatingsystem => 'CentOS' }, - { :osfamily => 'RedHat', :operatingsystemrelease => '7.1', :operatingsystem => 'CentOS' }, - ].each do |myfacts| + on_supported_os.each do |os, facts| + context "on #{os}" do + let(:facts) do + facts + end + let :pre_condition do + 'include ::graphite' + end + + it { is_expected.to compile.with_all_deps } + it { is_expected.to contain_class('graphite::params') } + it { is_expected.to contain_exec('Initial django db creation') } + it { is_expected.to contain_class('graphite::config_apache') } - context 'OS %s %s' % myfacts.values do - let :facts do myfacts end - let :pre_condition do 'include ::graphite' end + # cron check + it { is_expected.to contain_file('/opt/graphite/bin/carbon-logrotate.sh').with({ + 'ensure' => 'file', 'mode' => '0544', 'content' => /^CARBON_LOGS_PATH="\/opt\/graphite\/storage\/log"$/ }) } + it { is_expected.to contain_cron('Rotate carbon logs').with({ + 'command' => '/opt/graphite/bin/carbon-logrotate.sh', + 'hour' => '3', + 'minute' => '15', + 'require' => 'File[/opt/graphite/bin/carbon-logrotate.sh]', + 'user' => 'root',}) } - case myfacts[:osfamily] + case facts[:osfamily] when 'Debian' then - case myfacts[:lsbdistcodename] - when 'capybara' then - it_behaves_like 'Debian unsupported platforms' - else - it_behaves_like 'supported platforms' - it_behaves_like 'Debian supported platforms' - - end + it_behaves_like 'Debian supported platforms' when 'RedHat' then - case myfacts[:operatingsystemrelease] - when /^[6-7]/ then - it_behaves_like 'supported platforms' - it_behaves_like 'RedHat supported platforms' - case myfacts[:operatingsystemrelease] - when /^6/ then - it_behaves_like 'RedHat 6 platforms' - when /^7/ then - it_behaves_like 'RedHat 7 platforms' - end - + it_behaves_like 'RedHat supported platforms' + case facts[:operatingsystemrelease] + when /^6/ then + it_behaves_like 'RedHat 6 platforms' + when /^7/ then + it_behaves_like 'RedHat 7 platforms' else - it_behaves_like 'RedHat unsupported platforms' + it { is_expected.to raise_error(Puppet::Error,/unsupported os,.+\./ )} end else - it_behaves_like 'Unsupported OS' + it { is_expected.to raise_error(Puppet::Error,/unsupported os,.+\./ )} end + end end + end diff --git a/spec/classes/graphite_spec.rb b/spec/classes/graphite_spec.rb index b7b2729a..aa72f9b8 100644 --- a/spec/classes/graphite_spec.rb +++ b/spec/classes/graphite_spec.rb @@ -2,54 +2,23 @@ describe 'graphite', :type => 'class' do - shared_context 'supported' do - it { is_expected.to contain_anchor('graphite::begin').that_comes_before( - 'Class[graphite::install]') } - it { is_expected.to contain_class('graphite::install').that_notifies( - 'Class[graphite::config]') } - it { is_expected.to contain_class('graphite::config').that_comes_before( - 'Anchor[graphite::end]') } - it { is_expected.to contain_anchor('graphite::end') } - end - context 'Unsupported OS' do let(:facts) {{ :osfamily => 'unsupported', :operatingsystem => 'UnknownOS' }} it { is_expected.to raise_error(Puppet::Error,/unsupported os,.+\./ )} end - context 'RedHat supported platforms' do - ['6.5','7.5'].each do | operatingsystemrelease | - let(:facts) {{ :osfamily => 'RedHat', :operatingsystemrelease => operatingsystemrelease}} - describe "Release #{operatingsystemrelease}" do - it_behaves_like 'supported' + on_supported_os.each do |os, facts| + context "on #{os}" do + let(:facts) do + facts end - end - end + + it { is_expected.to compile.with_all_deps } + it { is_expected.to contain_anchor('graphite::begin').that_comes_before('Class[graphite::install]') } + it { is_expected.to contain_class('graphite::install').that_notifies('Class[graphite::config]') } + it { is_expected.to contain_class('graphite::config').that_comes_before('Anchor[graphite::end]') } + it { is_expected.to contain_anchor('graphite::end') } - context 'RedHat unsupported platforms' do - ['5.0'].each do | operatingsystemrelease | - let(:facts) {{ :osfamily => 'RedHat', :operatingsystemrelease => operatingsystemrelease}} - describe "Redhat #{operatingsystemrelease} fails" do - it { expect { is_expected.to contain_class('graphite')}.to raise_error(Puppet::Error, /Unsupported RedHat release/) } - end - end - end - - context 'Debian supported platforms' do - ['trusty','squeeze', 'vivid', 'precise'].each do | lsbdistcodename | - let(:facts) {{ :osfamily => 'Debian', :lsbdistcodename => lsbdistcodename}} - describe "Lsbdistcodename #{lsbdistcodename}" do - it_behaves_like 'supported' - end - end - end - - context 'Debian unsupported platforms' do - ['capybara'].each do | lsbdistcodename | - let(:facts) {{ :osfamily => 'Debian', :lsbdistcodename => lsbdistcodename}} - describe "Debian #{lsbdistcodename} fails" do - it { expect { is_expected.to contain_class('graphite')}.to raise_error(Puppet::Error, /Unsupported Debian release/) } - end end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index b67e6bae..8b1578fc 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,23 +1,11 @@ if ENV['COVERAGE'] == 'yes' - require 'simplecov' - require 'coveralls' - - SimpleCov.formatters = [ - SimpleCov::Formatter::HTMLFormatter, - Coveralls::SimpleCov::Formatter - ] - - #Coveralls.wear! - SimpleCov.start do - add_filter '/spec/' - add_filter '/.vendor/' - end -end - -RSpec.configure do |c| - c.after(:suite) do - RSpec::Puppet::Coverage.report! + RSpec.configure do |c| + c.after(:suite) do + RSpec::Puppet::Coverage.report! + end end end require 'puppetlabs_spec_helper/module_spec_helper' +require 'rspec-puppet-facts' +include RspecPuppetFacts \ No newline at end of file diff --git a/templates/etc/init.d/RedHat/carbon-aggregator.erb b/templates/etc/init.d/RedHat/carbon-aggregator.erb index e484c664..aeb8f49f 100644 --- a/templates/etc/init.d/RedHat/carbon-aggregator.erb +++ b/templates/etc/init.d/RedHat/carbon-aggregator.erb @@ -21,7 +21,8 @@ PYTHON_CMD='python -W ignore' CARBON_DAEMON="aggregator" -GRAPHITE_DIR="/opt/graphite" +GRAPHITE_DIR="<%= scope.lookupvar('graphite::base_dir_REAL') %>" +PIDFILE_DIR="<%= scope.lookupvar('graphite::storage_dir_REAL') %>" pidfile="" OPERATION="$1" if [ $# -gt 1 ]; then @@ -37,14 +38,14 @@ start() if [ "${INSTANCE}" = "${CARBON_DAEMON}" ]; then INSTANCE="a"; fi; - pidfile=${GRAPHITE_DIR}/storage/carbon-${CARBON_DAEMON}-${INSTANCE}.pid + pidfile=${PIDFILE_DIR}/carbon-${CARBON_DAEMON}-${INSTANCE}.pid prog=carbon-${CARBON_DAEMON}-${INSTANCE} # check if instance is already running rh_status_q && continue ${PYTHON_CMD} ${GRAPHITE_DIR}/bin/carbon-${CARBON_DAEMON}.py --instance=${INSTANCE} start; retval=$? - pidfile=${GRAPHITE_DIR}/storage/carbon-${CARBON_DAEMON}-${INSTANCE}.pid + pidfile=${PIDFILE_DIR}/carbon-${CARBON_DAEMON}-${INSTANCE}.pid echo -n $"Starting carbon-${CARBON_DAEMON}:${INSTANCE}..." sleep 1 if rh_status_q; then @@ -66,14 +67,14 @@ stop() if [ "${INSTANCE}" = "${CARBON_DAEMON}" ]; then INSTANCE="a"; fi; - pidfile=${GRAPHITE_DIR}/storage/carbon-${CARBON_DAEMON}-${INSTANCE}.pid + pidfile=${PIDFILE_DIR}/carbon-${CARBON_DAEMON}-${INSTANCE}.pid prog=carbon-${CARBON_DAEMON}-${INSTANCE} # check if instance is already stopped rh_status_q || continue ${PYTHON_CMD} ${GRAPHITE_DIR}/bin/carbon-${CARBON_DAEMON}.py --instance=${INSTANCE} stop; sleep 3 - while [ -f ${GRAPHITE_DIR}/storage/carbon-${CARBON_DAEMON}-${INSTANCE}.pid ]; do + while [ -f ${PIDFILE_DIR}/carbon-${CARBON_DAEMON}-${INSTANCE}.pid ]; do echo "waiting another 5 secs for carbon-${CARBON_DAEMON}-${INSTANCE} to stop" sleep 5 #TODO: add timer to prevend endless waiting @@ -93,12 +94,12 @@ restart() { if [ "${INSTANCE}" = "${CARBON_DAEMON}" ]; then INSTANCE="a"; fi; - pidfile=${GRAPHITE_DIR}/storage/carbon-${CARBON_DAEMON}-${INSTANCE}.pid + pidfile=${PIDFILE_DIR}/carbon-${CARBON_DAEMON}-${INSTANCE}.pid prog=carbon-${CARBON_DAEMON}-${INSTANCE} ${PYTHON_CMD} ${GRAPHITE_DIR}/bin/carbon-${CARBON_DAEMON}.py --instance=${INSTANCE} stop; sleep 3 - while [ -f ${GRAPHITE_DIR}/storage/carbon-${CARBON_DAEMON}-${INSTANCE}.pid ]; do + while [ -f ${PIDFILE_DIR}/carbon-${CARBON_DAEMON}-${INSTANCE}.pid ]; do echo "waiting another 5 secs for carbon-${CARBON_DAEMON}-${INSTANCE} to stop" sleep 5 #TODO: add timer to prevend endless waiting @@ -110,7 +111,7 @@ restart() { ${PYTHON_CMD} ${GRAPHITE_DIR}/bin/carbon-${CARBON_DAEMON}.py --instance=${INSTANCE} start; retval=$? - pidfile=${GRAPHITE_DIR}/storage/carbon-${CARBON_DAEMON}-${INSTANCE}.pid + pidfile=${PIDFILE_DIR}/carbon-${CARBON_DAEMON}-${INSTANCE}.pid echo -n $"Starting carbon-${CARBON_DAEMON}:${INSTANCE}..." sleep 1 if rh_status_q; then @@ -160,7 +161,7 @@ case "${OPERATION}" in ;; condrestart|try-restart) # TODO: bad behavior. only checking instance "a" at the moment - pidfile=${GRAPHITE_DIR}/storage/carbon-${CARBON_DAEMON}-a.pid + pidfile=${PIDFILE_DIR}/carbon-${CARBON_DAEMON}-a.pid prog=carbon-${CARBON_DAEMON}-a rh_status_q || exit 0 restart @@ -170,7 +171,7 @@ case "${OPERATION}" in if [ "${INSTANCE}" = "${CARBON_DAEMON}" ]; then INSTANCE="a"; fi; - pidfile=${GRAPHITE_DIR}/storage/carbon-${CARBON_DAEMON}-${INSTANCE}.pid + pidfile=${PIDFILE_DIR}/carbon-${CARBON_DAEMON}-${INSTANCE}.pid prog=carbon-${CARBON_DAEMON}-${INSTANCE} rh_status done diff --git a/templates/etc/init.d/RedHat/carbon-cache.erb b/templates/etc/init.d/RedHat/carbon-cache.erb index b53c5647..f659a22d 100644 --- a/templates/etc/init.d/RedHat/carbon-cache.erb +++ b/templates/etc/init.d/RedHat/carbon-cache.erb @@ -22,6 +22,7 @@ PYTHON_CMD='python -W ignore' CARBON_DAEMON="cache" GRAPHITE_DIR="<%= scope.lookupvar('graphite::base_dir_REAL') %>" +PIDFILE_DIR="<%= scope.lookupvar('graphite::storage_dir_REAL') %>" pidfile="" OPERATION="$1" if [ $# -gt 1 ]; then @@ -37,7 +38,7 @@ start() if [ "${INSTANCE}" = "${CARBON_DAEMON}" ]; then INSTANCE="a"; fi; - pidfile=<%= scope.lookupvar('graphite::gr_pid_dir') %>/carbon-${CARBON_DAEMON}-${INSTANCE}.pid + pidfile=${PIDFILE_DIR}/carbon-${CARBON_DAEMON}-${INSTANCE}.pid prog=carbon-${CARBON_DAEMON}-${INSTANCE} # check if instance is already running rh_status_q && continue @@ -48,7 +49,7 @@ start() ${PYTHON_CMD} ${CARBON_PY} --instance=${INSTANCE} start; retval=$? - pidfile=${GRAPHITE_DIR}/storage/carbon-${CARBON_DAEMON}-${INSTANCE}.pid + pidfile=${PIDFILE_DIR}/carbon-${CARBON_DAEMON}-${INSTANCE}.pid echo -n $"Starting carbon-${CARBON_DAEMON}:${INSTANCE}..." sleep 1 if rh_status_q; then @@ -70,14 +71,14 @@ stop() if [ "${INSTANCE}" = "${CARBON_DAEMON}" ]; then INSTANCE="a"; fi; - pidfile=${GRAPHITE_DIR}/storage/carbon-${CARBON_DAEMON}-${INSTANCE}.pid + pidfile=${PIDFILE_DIR}/carbon-${CARBON_DAEMON}-${INSTANCE}.pid prog=carbon-${CARBON_DAEMON}-${INSTANCE} # check if instance is already stopped rh_status_q || continue ${PYTHON_CMD} ${GRAPHITE_DIR}/bin/carbon-${CARBON_DAEMON}.py --instance=${INSTANCE} stop; sleep 3 - while [ -f ${GRAPHITE_DIR}/storage/carbon-${CARBON_DAEMON}-${INSTANCE}.pid ]; do + while [ -f ${PIDFILE_DIR}/carbon-${CARBON_DAEMON}-${INSTANCE}.pid ]; do echo "waiting another 5 secs for carbon-${CARBON_DAEMON}-${INSTANCE} to stop" sleep 5 #TODO: add timer to prevend endless waiting @@ -97,12 +98,12 @@ restart() { if [ "${INSTANCE}" = "${CARBON_DAEMON}" ]; then INSTANCE="a"; fi; - pidfile=${GRAPHITE_DIR}/storage/carbon-${CARBON_DAEMON}-${INSTANCE}.pid + pidfile=${PIDFILE_DIR}/carbon-${CARBON_DAEMON}-${INSTANCE}.pid prog=carbon-${CARBON_DAEMON}-${INSTANCE} ${PYTHON_CMD} ${GRAPHITE_DIR}/bin/carbon-${CARBON_DAEMON}.py --instance=${INSTANCE} stop; sleep 3 - while [ -f ${GRAPHITE_DIR}/storage/carbon-${CARBON_DAEMON}-${INSTANCE}.pid ]; do + while [ -f ${PIDFILE_DIR}/carbon-${CARBON_DAEMON}-${INSTANCE}.pid ]; do echo "waiting another 5 secs for carbon-${CARBON_DAEMON}-${INSTANCE} to stop" sleep 5 #TODO: add timer to prevend endless waiting @@ -114,7 +115,7 @@ restart() { ${PYTHON_CMD} ${GRAPHITE_DIR}/bin/carbon-${CARBON_DAEMON}.py --instance=${INSTANCE} start; retval=$? - pidfile=${GRAPHITE_DIR}/storage/carbon-${CARBON_DAEMON}-${INSTANCE}.pid + pidfile=$${PIDFILE_DIR}/carbon-${CARBON_DAEMON}-${INSTANCE}.pid echo -n $"Starting carbon-${CARBON_DAEMON}:${INSTANCE}..." sleep 1 if rh_status_q; then @@ -164,7 +165,7 @@ case "${OPERATION}" in ;; condrestart|try-restart) # TODO: bad behavior. only checking instance "a" at the moment - pidfile=${GRAPHITE_DIR}/storage/carbon-${CARBON_DAEMON}-a.pid + pidfile=${PIDFILE_DIR}/carbon-${CARBON_DAEMON}-a.pid prog=carbon-${CARBON_DAEMON}-a rh_status_q || exit 0 restart @@ -174,7 +175,7 @@ case "${OPERATION}" in if [ "${INSTANCE}" = "${CARBON_DAEMON}" ]; then INSTANCE="a"; fi; - pidfile=${GRAPHITE_DIR}/storage/carbon-${CARBON_DAEMON}-${INSTANCE}.pid + pidfile=${PIDFILE_DIR}/carbon-${CARBON_DAEMON}-${INSTANCE}.pid prog=carbon-${CARBON_DAEMON}-${INSTANCE} rh_status done diff --git a/templates/etc/init.d/RedHat/carbon-relay.erb b/templates/etc/init.d/RedHat/carbon-relay.erb index 55dd6f18..7a978efb 100644 --- a/templates/etc/init.d/RedHat/carbon-relay.erb +++ b/templates/etc/init.d/RedHat/carbon-relay.erb @@ -21,7 +21,8 @@ PYTHON_CMD='python -W ignore' CARBON_DAEMON="relay" -GRAPHITE_DIR="/opt/graphite" +GRAPHITE_DIR="<%= scope.lookupvar('graphite::base_dir_REAL') %>" +PIDFILE_DIR="<%= scope.lookupvar('graphite::storage_dir_REAL') %>" pidfile="" OPERATION="$1" if [ $# -gt 1 ]; then @@ -40,14 +41,14 @@ start() <% if @gr_carbon_relay_ulimit -%> ulimit -n <%= @gr_carbon_relay_ulimit %> <% end -%> - pidfile=${GRAPHITE_DIR}/storage/carbon-${CARBON_DAEMON}-${INSTANCE}.pid + pidfile=${PIDFILE_DIR}/carbon-${CARBON_DAEMON}-${INSTANCE}.pid prog=carbon-${CARBON_DAEMON}-${INSTANCE} # check if instance is already running rh_status_q && continue ${PYTHON_CMD} ${GRAPHITE_DIR}/bin/carbon-${CARBON_DAEMON}.py --instance=${INSTANCE} start; retval=$? - pidfile=${GRAPHITE_DIR}/storage/carbon-${CARBON_DAEMON}-${INSTANCE}.pid + pidfile=${PIDFILE_DIR}/carbon-${CARBON_DAEMON}-${INSTANCE}.pid echo -n $"Starting carbon-${CARBON_DAEMON}:${INSTANCE}..." sleep 1 if rh_status_q; then @@ -69,14 +70,14 @@ stop() if [ "${INSTANCE}" = "${CARBON_DAEMON}" ]; then INSTANCE="a"; fi; - pidfile=${GRAPHITE_DIR}/storage/carbon-${CARBON_DAEMON}-${INSTANCE}.pid + pidfile=${PIDFILE_DIR}/carbon-${CARBON_DAEMON}-${INSTANCE}.pid prog=carbon-${CARBON_DAEMON}-${INSTANCE} # check if instance is already stopped rh_status_q || continue ${PYTHON_CMD} ${GRAPHITE_DIR}/bin/carbon-${CARBON_DAEMON}.py --instance=${INSTANCE} stop; sleep 3 - while [ -f ${GRAPHITE_DIR}/storage/carbon-${CARBON_DAEMON}-${INSTANCE}.pid ]; do + while [ -f ${PIDFILE_DIR}/carbon-${CARBON_DAEMON}-${INSTANCE}.pid ]; do echo "waiting another 5 secs for carbon-${CARBON_DAEMON}-${INSTANCE} to stop" sleep 5 #TODO: add timer to prevend endless waiting @@ -96,12 +97,12 @@ restart() { if [ "${INSTANCE}" = "${CARBON_DAEMON}" ]; then INSTANCE="a"; fi; - pidfile=${GRAPHITE_DIR}/storage/carbon-${CARBON_DAEMON}-${INSTANCE}.pid + pidfile=${PIDFILE_DIR}/carbon-${CARBON_DAEMON}-${INSTANCE}.pid prog=carbon-${CARBON_DAEMON}-${INSTANCE} ${PYTHON_CMD} ${GRAPHITE_DIR}/bin/carbon-${CARBON_DAEMON}.py --instance=${INSTANCE} stop; sleep 3 - while [ -f ${GRAPHITE_DIR}/storage/carbon-${CARBON_DAEMON}-${INSTANCE}.pid ]; do + while [ -f ${PIDFILE_DIR}/carbon-${CARBON_DAEMON}-${INSTANCE}.pid ]; do echo "waiting another 5 secs for carbon-${CARBON_DAEMON}-${INSTANCE} to stop" sleep 5 #TODO: add timer to prevend endless waiting @@ -113,7 +114,7 @@ restart() { ${PYTHON_CMD} ${GRAPHITE_DIR}/bin/carbon-${CARBON_DAEMON}.py --instance=${INSTANCE} start; retval=$? - pidfile=${GRAPHITE_DIR}/storage/carbon-${CARBON_DAEMON}-${INSTANCE}.pid + pidfile=${PIDFILE_DIR}/carbon-${CARBON_DAEMON}-${INSTANCE}.pid echo -n $"Starting carbon-${CARBON_DAEMON}:${INSTANCE}..." sleep 1 if rh_status_q; then @@ -163,7 +164,7 @@ case "${OPERATION}" in ;; condrestart|try-restart) # TODO: bad behavior. only checking instance "a" at the moment - pidfile=${GRAPHITE_DIR}/storage/carbon-${CARBON_DAEMON}-a.pid + pidfile=${PIDFILE_DIR}/carbon-${CARBON_DAEMON}-a.pid prog=carbon-${CARBON_DAEMON}-a rh_status_q || exit 0 restart @@ -173,7 +174,7 @@ case "${OPERATION}" in if [ "${INSTANCE}" = "${CARBON_DAEMON}" ]; then INSTANCE="a"; fi; - pidfile=${GRAPHITE_DIR}/storage/carbon-${CARBON_DAEMON}-${INSTANCE}.pid + pidfile=${PIDFILE_DIR}/carbon-${CARBON_DAEMON}-${INSTANCE}.pid prog=carbon-${CARBON_DAEMON}-${INSTANCE} rh_status done