Skip to content

Commit

Permalink
Source zookeeper-env.sh when running ZooKeeper
Browse files Browse the repository at this point in the history
  • Loading branch information
jaybocc2 authored and jeffbyrnes committed Feb 1, 2018
1 parent bea4bdf commit 88a38b0
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions recipes/service.rb
Expand Up @@ -18,5 +18,6 @@
zookeeper_service 'zookeeper' do
service_style node['zookeeper']['service_style']
install_dir "#{node['zookeeper']['install_dir']}/zookeeper"
conf_dir node['zookeeper']['conf_dir']
username node['zookeeper']['user']
end
6 changes: 5 additions & 1 deletion resources/service.rb
Expand Up @@ -25,13 +25,15 @@
-> (service_style) { %w(runit upstart systemd exhibitor).include? service_style },
}
property :install_dir, default: '/opt/zookeeper'
property :conf_dir, default: '/opt/zookeeper/conf'
property :username, default: 'zookeeper'
property :service_actions, default: [:enable, :start]
property :template_cookbook, default: 'zookeeper'
property :restart_on_reconfig, default: false

action :create do
executable_path = "#{new_resource.install_dir}/bin/zkServer.sh"
env_path = "#{new_resource.conf_dir}/zookeeper-env.sh"

case new_resource.service_style
when 'runit'
Expand All @@ -43,6 +45,7 @@
owner new_resource.username
group new_resource.username
options(
zk_env: env_path,
exec: executable_path,
username: new_resource.username
)
Expand All @@ -54,6 +57,7 @@
source 'zookeeper.upstart.erb'
mode '0644'
variables(
zk_env: env_path,
exec: executable_path,
username: new_resource.username
)
Expand All @@ -71,6 +75,7 @@
source 'zookeeper.systemd.erb'
mode '0644'
variables(
zk_env: env_path,
exec: executable_path,
username: new_resource.username
)
Expand All @@ -89,7 +94,6 @@
supports status: true, restart: true, nothing: true
action new_resource.service_actions
end

when 'exhibitor'
Chef::Log.info 'Assuming Exhibitor will start up Zookeeper.'
end
Expand Down
1 change: 1 addition & 0 deletions templates/default/sv-zookeeper-run.erb
@@ -1,3 +1,4 @@
#!/bin/sh

source <%= @options[:zk_env] %>
exec chpst -u<%= @options[:username] %> <%= @options[:exec] %> start-foreground
1 change: 1 addition & 0 deletions templates/default/zookeeper.systemd.erb
Expand Up @@ -9,6 +9,7 @@ After=network.target
User=<%= @username %>
Group=<%= @username %>
SyslogIdentifier=zookeeper
EnvironmentFile=<%= @zk_env %>
Restart=on-failure
ExecStart=<%= @exec %> start-foreground
LimitNOFILE=8192
Expand Down
2 changes: 2 additions & 0 deletions templates/default/zookeeper.upstart.erb
Expand Up @@ -16,5 +16,7 @@ setuid <%= @username %>
setgid <%= @username %>

script
set -a
source <%= @zk_env %>
exec <%= @exec %> start-foreground
end script

0 comments on commit 88a38b0

Please sign in to comment.