From f0ba5e5077cdb63e7a4d2ccdd395465ee29fe34a Mon Sep 17 00:00:00 2001 From: Guillaume Thouvenin Date: Wed, 23 Mar 2016 15:17:53 +0100 Subject: [PATCH] Avoid forks when starting hekad We must avoid to fork process when starting the Heka daemon because if we kill the wrapper, the Heka daemon is detached and re-attach to the init process. This can create several Heka daemon. To avoid this we need to use exec and avoid the usage of sudo. Fixes-bug: #1561109 Change-Id: Idbfab2de92b993d1e5124de5bff44c4b09a88bb4 --- .../puppet/modules/heka/spec/classes/heka_spec.rb | 4 ++-- .../puppet/modules/heka/templates/hekad.upstart.conf.erb | 2 +- .../puppet/modules/heka/templates/hekad_wrapper.erb | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/deployment_scripts/puppet/modules/heka/spec/classes/heka_spec.rb b/deployment_scripts/puppet/modules/heka/spec/classes/heka_spec.rb index 125040157..e75465dba 100644 --- a/deployment_scripts/puppet/modules/heka/spec/classes/heka_spec.rb +++ b/deployment_scripts/puppet/modules/heka/spec/classes/heka_spec.rb @@ -22,7 +22,7 @@ describe 'heka' do describe 'with defaults' do it { is_expected.to contain_user('heka') } it { is_expected.to contain_file('/etc/init/hekad.conf') \ - .with_content(/sudo -u heka/) } + .with_content(/--user heka/) } end describe 'with user => "root"' do @@ -32,6 +32,6 @@ describe 'heka' do it { is_expected.to contain_user('root') } it { is_expected.to contain_file('/etc/init/hekad.conf') } it { is_expected.not_to contain_file('/etc/init/hekad.conf') \ - .with_content(/sudo -u/) } + .with_content(/--user/) } end end diff --git a/deployment_scripts/puppet/modules/heka/templates/hekad.upstart.conf.erb b/deployment_scripts/puppet/modules/heka/templates/hekad.upstart.conf.erb index 601e455c8..6b6930722 100644 --- a/deployment_scripts/puppet/modules/heka/templates/hekad.upstart.conf.erb +++ b/deployment_scripts/puppet/modules/heka/templates/hekad.upstart.conf.erb @@ -17,5 +17,5 @@ end script script # https://bugs.launchpad.net/lma-toolchain/+bug/1543289 ulimit -n 102400 - exec <%= @run_as_root ? "" : "sudo -u #{ @heka_user }" %> <%= @hekad_wrapper %> 2>><%= @log_file %> + exec start-stop-daemon --start <%= @run_as_root ? "" : " --user #{ @heka_user }" %> --exec <%= @hekad_wrapper %> 2>><%= @log_file %> end script diff --git a/deployment_scripts/puppet/modules/heka/templates/hekad_wrapper.erb b/deployment_scripts/puppet/modules/heka/templates/hekad_wrapper.erb index e233e751a..9a93d092c 100644 --- a/deployment_scripts/puppet/modules/heka/templates/hekad_wrapper.erb +++ b/deployment_scripts/puppet/modules/heka/templates/hekad_wrapper.erb @@ -6,4 +6,4 @@ HEKAD="/usr/bin/hekad" <%= @pre_script %> <% end -%> -$HEKAD -config=<%= @config_dir %> +exec $HEKAD -config=<%= @config_dir %>