diff --git a/recipes/warden.rb b/recipes/warden.rb index a30da26..7483f3a 100644 --- a/recipes/warden.rb +++ b/recipes/warden.rb @@ -37,3 +37,12 @@ mode '744' variables(config: node['mapr']['warden']['daemon']['config']) end + +# Replace the default systemd service unit to make it compatible with systemd-219-67 +template '/etc/systemd/system/mapr-warden.service' do + source 'systemd_warden.erb' + owner 'root' + group 'root' + mode '0755' + variables(user: node['mapr']['config']['owner']) +end \ No newline at end of file diff --git a/recipes/zookeeper.rb b/recipes/zookeeper.rb index 9838527..17baafc 100644 --- a/recipes/zookeeper.rb +++ b/recipes/zookeeper.rb @@ -55,6 +55,15 @@ variables(config: config.hash) end +# Replace the default systemd service unit to make it compatible with systemd-219-67 +template '/etc/systemd/system/mapr-zookeeper.service' do + source 'systemd_zookeeper.erb' + owner 'root' + group 'root' + mode '0755' + variables(user: node['mapr']['config']['owner']) +end + service 'mapr-zookeeper' do action %w[start enable] end diff --git a/spec/unit/recipes/warden_spec.rb b/spec/unit/recipes/warden_spec.rb index 1b2ae09..ef1f106 100644 --- a/spec/unit/recipes/warden_spec.rb +++ b/spec/unit/recipes/warden_spec.rb @@ -67,5 +67,8 @@ }, ) end + it 'should create the warden systemd unit file' do + expect(chef_run).to render_file('/etc/systemd/system/mapr-warden.service').with_content(/User=mapr/) + end end end diff --git a/spec/unit/recipes/zookeeper_spec.rb b/spec/unit/recipes/zookeeper_spec.rb index e2fc949..31bbf29 100644 --- a/spec/unit/recipes/zookeeper_spec.rb +++ b/spec/unit/recipes/zookeeper_spec.rb @@ -126,6 +126,9 @@ it 'should include the recipe default' do expect(chef_run).to include_recipe('mapr') end + it 'should create the zookeeper systemd unit file' do + expect(chef_run).to render_file('/etc/systemd/system/mapr-zookeeper.service').with_content(/User=mapr/) + end end end # rubocop: enable BlockLength diff --git a/templates/default/systemd_warden.erb b/templates/default/systemd_warden.erb new file mode 100644 index 0000000..90ac9ff --- /dev/null +++ b/templates/default/systemd_warden.erb @@ -0,0 +1,21 @@ +[Unit] +Description=MapR Technologies, Inc. warden services +Requires=multi-user.target + +[Service] +User=<%= @user %> +ExecStop=/opt/mapr/initscripts/mapr-warden stop +ExecStart=/opt/mapr/initscripts/mapr-warden start +ExecReload=/opt/mapr/initscripts/mapr-warden reload +PIDFile=/opt/mapr/pid/warden.pid +Restart=on-failure +RestartSec=10 +StartLimitBurst=3 +StartLimitInterval=60s +TimeoutStopSec=300 + +SuccessExitStatus=130 143 +Type=forking + +[Install] +WantedBy=default.target diff --git a/templates/default/systemd_zookeeper.erb b/templates/default/systemd_zookeeper.erb new file mode 100644 index 0000000..67cefeb --- /dev/null +++ b/templates/default/systemd_zookeeper.erb @@ -0,0 +1,20 @@ +[Unit] +Description=MapR Technologies, Inc. zookeeper service +After=rc-local.service +After=network.target syslog.target + +[Service] +User=<%= @user %> +ExecStop=/opt/mapr/initscripts/zookeeper stop +ExecStart=/opt/mapr/initscripts/zookeeper start +PIDFile=/opt/mapr/pid/zookeeper.pid +Restart=on-failure +RestartSec=10 +StartLimitBurst=3 +StartLimitInterval=60s + +SuccessExitStatus=9 130 143 SIGKILL +Type=forking + +[Install] +WantedBy=default.target