Skip to content

Commit

Permalink
Merge pull request #1 from seomoz/corbin/update-chef-version
Browse files Browse the repository at this point in the history
Corbin/update chef version
  • Loading branch information
CorbinGraham authored Feb 26, 2024
2 parents afc51c4 + e65e585 commit 2b37b37
Show file tree
Hide file tree
Showing 14 changed files with 177 additions and 157 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Requirements
Chef version 0.10.10+ and Ohai 0.6.12+ are required.

### Platform
* Ubuntu 12.10
* Ubuntu 22.02

**Notes**: This cookbook has been tested on the listed platforms only. It may work on other platforms with modification.

Expand Down
2 changes: 1 addition & 1 deletion metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
version '1.2.3'
issues_url 'https://github.com/simplereach/chef-nsq/issues'
source_url 'https://github.com/simplereach/chef-nsq'
chef_version '11.18.6'
chef_version '12.21.31'

supports 'debian', '>= 6.0'
supports 'ubuntu', '>= 10.04'
Expand Down
13 changes: 10 additions & 3 deletions recipes/nsqadmin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,24 @@
nsq_release = "nsq-#{node['nsq']['version']}-#{node['nsq']['go_version']}"

if node['nsq']['setup_services']
template '/etc/init/nsqadmin.conf' do
template '/usr/local/sbin/nsqadmin.sh' do
action :create
source 'upstart.nsqadmin.conf.erb'
source 'nsqadmin.sh'
owner 'root'
mode '0755'
end

template '/etc/systemd/system/nsqadmin.service' do
action :create
source 'nsqadmin.service'
mode '0644'
# need to stop/start in order to reload config
notifies :stop, 'service[nsqadmin]', :immediately
notifies :start, 'service[nsqadmin]', :immediately
end

service 'nsqadmin' do
provider Chef::Provider::Service::Upstart
provider Chef::Provider::Service::Systemd
action [:enable, :start]
supports stop: true, start: true, restart: true, status: true
subscribes :restart, "ark[#{nsq_release}]", :delayed
Expand Down
15 changes: 11 additions & 4 deletions recipes/nsqd.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,24 @@
end

if node['nsq']['setup_services']
template '/etc/init/nsqd.conf' do
template '/usr/local/sbin/nsqd.sh' do
action :create
source 'upstart.nsqd.conf.erb'
mode '0644'
source 'nsqd.sh'
owner 'root'
mode '0755'
end

template '/etc/systemd/system/nsqd.service' do
action :create
source 'nsqd.service'
mode '0644'
# need to stop/start in order to reload config
notifies :stop, 'service[nsqd]', :immediately
notifies :start, 'service[nsqd]', :immediately
end

service 'nsqd' do
provider Chef::Provider::Service::Upstart
provider Chef::Provider::Service::Systemd
action [:enable, :start]
supports stop: true, start: true, restart: true, status: true
subscribes :restart, "ark[#{nsq_release}]", :delayed
Expand Down
13 changes: 10 additions & 3 deletions recipes/nsqlookupd.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,24 @@
nsq_release = "nsq-#{node['nsq']['version']}-#{node['nsq']['go_version']}"

if node['nsq']['setup_services']
template '/etc/init/nsqlookupd.conf' do
template '/usr/local/sbin/nsqlookupd.sh' do
action :create
source 'upstart.nsqlookupd.conf.erb'
source 'nsqlookupd.sh'
owner 'root'
mode '0755'
end

template '/etc/systemd/system/nsqlookupd.service' do
action :create
source 'nsqlookupd.service'
mode '0644'
# need to stop/start in order to reload config
notifies :stop, 'service[nsqlookupd]', :immediately
notifies :start, 'service[nsqlookupd]', :immediately
end

service 'nsqlookupd' do
provider Chef::Provider::Service::Upstart
provider Chef::Provider::Service::Systemd
action [:enable, :start]
supports stop: true, start: true, restart: true, status: true
subscribes :restart, "ark[#{nsq_release}]", :delayed
Expand Down
11 changes: 11 additions & 0 deletions templates/default/nsqadmin.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[Unit]
Description=nsqadmin

[Service]
Type=simple
ExecStart=/usr/local/sbin/nsqadmin.sh
Environment=PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin
Restart=on-failure

[Install]
WantedBy=multi-user.target
20 changes: 20 additions & 0 deletions templates/default/nsqadmin.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

set -e
mkfifo /tmp/nsqadmin-log-fifo
( logger -t nsqadmin </tmp/nsqadmin-log-fifo & )
exec >/tmp/nsqadmin-log-fifo
rm /tmp/nsqadmin-log-fifo

exec su -s /bin/sh -c 'exec "$0" "$@"' <%= node["nsq"]["nsqadmin"]["user"] %> -- /usr/local/bin/nsqadmin \
--template-dir <%= node["nsq"]["nsqadmin"]["nsqd_template_dir"] %> \
<%- node["nsq"]["nsqadmin"]["lookupd_http_address"].each do |lookup_host| %>
--lookupd-http-address=<%= lookup_host %> \
<%- end %>
--use-statsd-prefixes=<%= node["nsq"]["nsqadmin"]["use_statsd_prefixes"] %> \
--statsd-interval=<%= node["nsq"]["nsqadmin"]["statsd_interval"] %> \
--proxy-graphite=<%= node["nsq"]["nsqadmin"]["proxy_graphite"] %> \
<% if node["nsq"]["nsqadmin"]["graphite_url"] != "" then %>
--graphite-url=<%= node["nsq"]["nsqadmin"]["graphite_url"] %> \
<% end %>
--http-address=<%= node["nsq"]["nsqadmin"]["http_address"] %> 2>&1
11 changes: 11 additions & 0 deletions templates/default/nsqd.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[Unit]
Description=nsqd

[Service]
Type=simple
ExecStart=/usr/local/sbin/nsqd.sh
Environment=PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin
Restart=on-failure

[Install]
WantedBy=multi-user.target
74 changes: 74 additions & 0 deletions templates/default/nsqd.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#!/bin/bash

set -e
mkfifo /tmp/nsqd-log-fifo
( logger -t nsqd </tmp/nsqd-log-fifo & )
exec >/tmp/nsqd-log-fifo
rm /tmp/nsqd-log-fifo

exec su -s /bin/sh -c 'exec "$0" "$@"' <%= node['nsq']['nsqd']['user'] %> -- /usr/local/bin/nsqd \
--data-path=<%= node['nsq']['nsqd']['data_path'] %> \
<%- if !node['nsq']['nsqd']['tls_required'] %>
--http-address=<%= node['nsq']['nsqd']['http_address'] %> \
<% end %>
<%- node['nsq']['nsqd']['lookupd_tcp_address'].each do |lookup_host| %>
--lookupd-tcp-address=<%= lookup_host %> \
<% end %>
<%- if Semantic::Version.new(node['nsq']['version']) > Semantic::Version.new('0.2.21') %>
--max-output-buffer-size=<%= node['nsq']['nsqd']['max_output_buffer_size'] %> \
--max-output-buffer-timeout=<%= node['nsq']['nsqd']['max_output_buffer_timeout'] %> \
<% end %>
<%- if Semantic::Version.new(node['nsq']['version']) > Semantic::Version.new('0.2.22') %>
--deflate=<%= node['nsq']['nsqd']['deflate'] %> \
--snappy=<%= node['nsq']['nsqd']['snappy'] %> \
--max-deflate-level=<%= node['nsq']['nsqd']['max_deflate_level'] %> \
<% end %>
<%- if Semantic::Version.new(node['nsq']['version']) > Semantic::Version.new('0.2.24') %>
--e2e-processing-latency-percentile=<%= node['nsq']['nsqd']['e2e_processing_latency_percentile'] %> \
--e2e-processing-latency-window-time=<%= node['nsq']['nsqd']['e2e_processing_latency_window_time'] %> \
<% end %>
<%- if Semantic::Version.new(node['nsq']['version']) >= Semantic::Version.new('0.2.27') %>
--max-msg-size=<%= node['nsq']['nsqd']['max_msg_size'] %> \
<%- else %>
--max-message-size=<%= node['nsq']['nsqd']['max_message_size'] %> \
<%- end %>
<%- if Semantic::Version.new(node['nsq']['version']) > Semantic::Version.new('0.2.28') %>
--https-address=<%= node['nsq']['nsqd']['https_address'] %> \
<%- if !node['nsq']['nsqd']['tls_client_auth_policy'].empty? %>
--tls-client-auth-policy=<%= node['nsq']['nsqd']['tls_client_auth_policy'] %> \
<%- end %>
<%- if !node['nsq']['nsqd']['tls_root_ca_file'].empty? %>
--tls-root-ca-file=<%= node['nsq']['nsqd']['tls_root_ca_file'] %>
<%- end %>
<% end %>
<%- if Semantic::Version.new(node['nsq']['version']) >= Semantic::Version.new('0.2.29') %>
--max-req-timeout=<%= node['nsq']['nsqd']['max_req_timeout'] %> \
<%- if !node['nsq']['nsqd']['auth_http_address'].empty? %>
--auth-http-address=<%= node['nsq']['nsqd']['auth_http_address'] %> \
<%- end %>
<%- end %>
<%- if !node['nsq']['nsqd']['tls_key'].empty? %>
--tls-key=<%= node['nsq']['nsqd']['tls_key'] %> \
<%- end %>
<%- if !node['nsq']['nsqd']['tls_cert'].empty? %>
--tls-cert=<%= node['nsq']['nsqd']['tls_cert'] %> \
<%- end %>
--max-body-size=<%= node['nsq']['nsqd']['max_body_size'] %> \
--max-bytes-per-file=<%= node['nsq']['nsqd']['max_bytes_per_file'] %> \
--max-msg-timeout=<%= node['nsq']['nsqd']['max_msg_timeout'] %> \
--max-rdy-count=<%= node['nsq']['nsqd']['max_rdy_count'] %> \
--mem-queue-size=<%= node['nsq']['nsqd']['mem_queue_size'] %> \
--msg-timeout=<%= node['nsq']['nsqd']['msg_timeout'] %> \
--statsd-address=<%= node['nsq']['nsqd']['statsd_address'] %> \
--statsd-interval=<%= node['nsq']['nsqd']['statsd_interval'] %> \
--statsd-mem-stats=<%= node['nsq']['nsqd']['statsd_mem_stats'] %> \
--statsd-prefix=<%= node['nsq']['nsqd']['statsd_prefix'] %> \
--sync-every=<%= node['nsq']['nsqd']['sync_every'] %> \
--sync-timeout=<%= node['nsq']['nsqd']['sync_timeout'] %> \
--tcp-address=<%= node['nsq']['nsqd']['tcp_address'] %> \
<%- if !node['nsq']['nsqd']['broadcast_address'].empty? %>
--broadcast-address=<%= node['nsq']['nsqd']['broadcast_address'] %> \
<%- else %>
--broadcast-address=<%= node['ipaddress'] %> \
<%- end %>
--verbose=<%= node['nsq']['nsqd']['verbose'] %> 2>&1
11 changes: 11 additions & 0 deletions templates/default/nsqlookupd.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[Unit]
Description=nsqlookupd

[Service]
Type=simple
ExecStart=/usr/local/sbin/nsqlookupd.sh
Environment=PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin
Restart=on-failure

[Install]
WantedBy=multi-user.target
17 changes: 17 additions & 0 deletions templates/default/nsqlookupd.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

set -e
mkfifo /tmp/nsqlookupd-log-fifo
( logger -t nsqlookupd </tmp/nsqlookupd-log-fifo & )
exec >/tmp/nsqlookupd-log-fifo
rm /tmp/nsqlookupd-log-fifo

exec su -s /bin/sh -c 'exec "$0" "$@"' <%= node["nsq"]["nsqlookupd"]["user"] %> -- /usr/local/bin/nsqlookupd \
--http-address <%= node["nsq"]["nsqlookupd"]["http_address"] %> \
--inactive-producer-timeout <%= node["nsq"]["nsqlookupd"]["inactive_producer_timeout"] %> \
--tcp-address <%= node["nsq"]["nsqlookupd"]["tcp_address"] %> \
<%- if !node['nsq']['nsqlookupd']['broadcast_address'].empty? %>
--broadcast-address <%= node["nsq"]["nsqlookupd"]["broadcast_address"] %> \
<%- end %>
--tombstone-lifetime <%= node["nsq"]["nsqlookupd"]["tombstone_lifetime"] %> \
--verbose <%= node["nsq"]["nsqlookupd"]["verbose"] %> 2>&1
29 changes: 0 additions & 29 deletions templates/default/upstart.nsqadmin.conf.erb

This file was deleted.

90 changes: 0 additions & 90 deletions templates/default/upstart.nsqd.conf.erb

This file was deleted.

Loading

0 comments on commit 2b37b37

Please sign in to comment.