From 1bc589ffc668252035920451f81fb2be390e821a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Greg=20Kar=C3=A9kinian?= Date: Tue, 8 Jan 2019 16:55:58 +0100 Subject: [PATCH] Move the creation of the SystemD service files outside of the application This prevents a crash on the initial Chef run due to the service files not being there yet before the services gets notified to restart --- .../kosmos-mastodon/recipes/default.rb | 80 +++++++++---------- 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/site-cookbooks/kosmos-mastodon/recipes/default.rb b/site-cookbooks/kosmos-mastodon/recipes/default.rb index 2e14300..58df06f 100644 --- a/site-cookbooks/kosmos-mastodon/recipes/default.rb +++ b/site-cookbooks/kosmos-mastodon/recipes/default.rb @@ -50,6 +50,46 @@ end ruby_version = "2.5.3" +execute "systemctl daemon-reload" do + command "systemctl daemon-reload" + action :nothing +end + +# mastodon-web service +# +template "/lib/systemd/system/mastodon-web.service" do + source "mastodon-web.systemd.service.erb" + variables user: user, + app_dir: mastodon_path, + port: node["kosmos-mastodon"]["puma_port"], + bundle_path: "/opt/ruby_build/builds/#{ruby_version}/bin/bundle" + notifies :run, "execute[systemctl daemon-reload]", :immediately + notifies :restart, "service[mastodon-web]", :delayed +end + +# mastodon-sidekiq service +# +template "/lib/systemd/system/mastodon-sidekiq.service" do + source "mastodon-sidekiq.systemd.service.erb" + variables user: user, + app_dir: mastodon_path, + bundle_path: "/opt/ruby_build/builds/#{ruby_version}/bin/bundle", + sidekiq_threads: node["kosmos-mastodon"]["sidekiq_threads"] + notifies :run, "execute[systemctl daemon-reload]", :immediately + notifies :restart, "service[mastodon-sidekiq]", :delayed +end + +# mastodon-streaming service +# +template "/lib/systemd/system/mastodon-streaming.service" do + source "mastodon-streaming.systemd.service.erb" + variables user: user, + app_dir: mastodon_path, + port: node["kosmos-mastodon"]["streaming_port"] + notifies :run, "execute[systemctl daemon-reload]", :immediately + notifies :restart, "service[mastodon-streaming]", :delayed +end + application mastodon_path do owner "mastodon" group "mastodon" @@ -127,54 +167,14 @@ application mastodon_path do command "PATH=\"/opt/ruby_build/builds/#{ruby_version}/bin:$PATH\" /opt/ruby_build/builds/#{ruby_version}/bin/bundle exec rake assets:precompile" end - execute "systemctl daemon-reload" do - command "systemctl daemon-reload" - action :nothing - end - - # mastodon-web service - # - template "/lib/systemd/system/mastodon-web.service" do - source "mastodon-web.systemd.service.erb" - variables user: user, - app_dir: mastodon_path, - port: node["kosmos-mastodon"]["puma_port"], - bundle_path: "/opt/ruby_build/builds/#{ruby_version}/bin/bundle" - notifies :run, "execute[systemctl daemon-reload]", :delayed - notifies :restart, "service[mastodon-web]", :delayed - end - service "mastodon-web" do action [:enable, :start] end - # mastodon-sidekiq service - # - template "/lib/systemd/system/mastodon-sidekiq.service" do - source "mastodon-sidekiq.systemd.service.erb" - variables user: user, - app_dir: mastodon_path, - bundle_path: "/opt/ruby_build/builds/#{ruby_version}/bin/bundle", - sidekiq_threads: node["kosmos-mastodon"]["sidekiq_threads"] - notifies :run, "execute[systemctl daemon-reload]", :delayed - notifies :restart, "service[mastodon-sidekiq]", :delayed - end - service "mastodon-sidekiq" do action [:enable, :start] end - # mastodon-streaming service - # - template "/lib/systemd/system/mastodon-streaming.service" do - source "mastodon-streaming.systemd.service.erb" - variables user: user, - app_dir: mastodon_path, - port: node["kosmos-mastodon"]["streaming_port"] - notifies :run, "execute[systemctl daemon-reload]", :delayed - notifies :restart, "service[mastodon-streaming]", :delayed - end - service "mastodon-streaming" do action [:enable, :start] end