Skip to content

Commit

Permalink
Fixing all of the other upstart files to work for Ubuntu 22.04
Browse files Browse the repository at this point in the history
  • Loading branch information
CorbinGraham committed Feb 1, 2024
1 parent 1926849 commit e65e585
Show file tree
Hide file tree
Showing 9 changed files with 80 additions and 62 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
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
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/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.

26 changes: 0 additions & 26 deletions templates/default/upstart.nsqlookupd.conf.erb

This file was deleted.

0 comments on commit e65e585

Please sign in to comment.