Browse Source

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
(cherry picked from commit f0ba5e5077)

Conflicts:
	deployment_scripts/puppet/modules/heka/spec/classes/heka_spec.rb

Change-Id: Idbfab2de92b993d1e5124de5bff44c4b09a88bb4
tags/0.8.1rc1^0
Guillaume Thouvenin 3 years ago
parent
commit
f2999dc559

+ 36
- 0
deployment_scripts/puppet/modules/heka/spec/classes/heka_spec.rb View File

@@ -0,0 +1,36 @@
1
+#    Copyright 2015 Mirantis, Inc.
2
+#
3
+#    Licensed under the Apache License, Version 2.0 (the "License"); you may
4
+#    not use this file except in compliance with the License. You may obtain
5
+#    a copy of the License at
6
+#
7
+#         http://www.apache.org/licenses/LICENSE-2.0
8
+#
9
+#    Unless required by applicable law or agreed to in writing, software
10
+#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11
+#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12
+#    License for the specific language governing permissions and limitations
13
+#    under the License.
14
+require 'spec_helper'
15
+
16
+describe 'heka' do
17
+    let(:facts) do
18
+        {:kernel => 'Linux', :operatingsystem => 'Ubuntu',
19
+         :osfamily => 'Debian'}
20
+    end
21
+
22
+    describe 'with defaults' do
23
+        it { is_expected.to contain_user('heka') }
24
+        it { is_expected.to contain_file('/etc/init/hekad.conf') \
25
+             .with_content(/--user heka/) }
26
+    end
27
+
28
+    describe 'with user => "root"' do
29
+        let(:params) do
30
+            {:run_as_root => true}
31
+        end
32
+        it { is_expected.to contain_file('/etc/init/hekad.conf') }
33
+        it { is_expected.not_to contain_file('/etc/init/hekad.conf') \
34
+             .with_content(/--user/) }
35
+    end
36
+end

+ 1
- 1
deployment_scripts/puppet/modules/heka/templates/hekad.upstart.conf.erb View File

@@ -17,5 +17,5 @@ end script
17 17
 script
18 18
     # https://bugs.launchpad.net/lma-toolchain/+bug/1543289
19 19
     ulimit -n 102400
20
-    exec <%= @run_as_root ? "" : "sudo -u #{ @heka_user }" %> <%= @hekad_wrapper %> 2>><%= @log_file %>
20
+    exec start-stop-daemon --start <%= @run_as_root ? "" : " --user #{ @heka_user }" %> --exec <%= @hekad_wrapper %> 2>><%= @log_file %>
21 21
 end script

+ 1
- 1
deployment_scripts/puppet/modules/heka/templates/hekad_wrapper.erb View File

@@ -6,4 +6,4 @@ HEKAD="/usr/bin/hekad"
6 6
 <%= @pre_script %>
7 7
 <% end -%>
8 8
 
9
-$HEKAD -config=<%= @config_dir %>
9
+exec $HEKAD -config=<%= @config_dir %>

Loading…
Cancel
Save