From 38756fd296199848daa4e65e440b62941acfde65 Mon Sep 17 00:00:00 2001 From: Sebastian Kippe Date: Sun, 5 Dec 2021 16:11:09 -0600 Subject: [PATCH 1/2] Upgrade Mastodon to latest version Using a new branch with freshly added Kosmos changes on top of the upstream release code. --- nodes/mastodon-1.json | 4 ++-- site-cookbooks/kosmos-mastodon/attributes/default.rb | 2 ++ site-cookbooks/kosmos-mastodon/recipes/default.rb | 8 ++++---- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/nodes/mastodon-1.json b/nodes/mastodon-1.json index df0c363..3be877f 100644 --- a/nodes/mastodon-1.json +++ b/nodes/mastodon-1.json @@ -8,7 +8,7 @@ "automatic": { "fqdn": "mastodon-1", "os": "linux", - "os_version": "5.4.0-1031-kvm", + "os_version": "5.4.0-1050-kvm", "hostname": "mastodon-1", "ipaddress": "192.168.122.197", "roles": [ @@ -18,7 +18,7 @@ "recipes": [ "kosmos-base", "kosmos-base::default", - "kosmos-postgresql::hostsfile", + "kosmos_postgresql::hostsfile", "kosmos-mastodon", "kosmos-mastodon::default", "kosmos-mastodon::nginx", diff --git a/site-cookbooks/kosmos-mastodon/attributes/default.rb b/site-cookbooks/kosmos-mastodon/attributes/default.rb index 0a92707..0110dfc 100644 --- a/site-cookbooks/kosmos-mastodon/attributes/default.rb +++ b/site-cookbooks/kosmos-mastodon/attributes/default.rb @@ -1,3 +1,5 @@ +node.default["kosmos-mastodon"]["repo"] = "https://gitea.kosmos.org/kosmos/mastodon.git" +node.default["kosmos-mastodon"]["revision"] = "kosmos-production" node.default["kosmos-mastodon"]["directory"] = "/opt/mastodon" node.default["kosmos-mastodon"]["puma_port"] = 3000 node.default["kosmos-mastodon"]["streaming_port"] = 4000 diff --git a/site-cookbooks/kosmos-mastodon/recipes/default.rb b/site-cookbooks/kosmos-mastodon/recipes/default.rb index 37cf214..e37d03b 100644 --- a/site-cookbooks/kosmos-mastodon/recipes/default.rb +++ b/site-cookbooks/kosmos-mastodon/recipes/default.rb @@ -46,7 +46,7 @@ npm_package "yarn" do version "1.22.4" end -ruby_version = "2.6.6" +ruby_version = "2.7.2" execute "systemctl daemon-reload" do command "systemctl daemon-reload" @@ -106,8 +106,8 @@ application mastodon_path do git do user mastodon_user group mastodon_user - repository "https://gitea.kosmos.org/kosmos/mastodon.git" - revision "production" + repository node["kosmos-mastodon"]["repo"] + revision node["kosmos-mastodon"]["revision"] # Restart services on deployments notifies :restart, "application[#{mastodon_path}]", :delayed end @@ -153,7 +153,7 @@ application mastodon_path do end execute 'rake db:migrate' do - environment "RAILS_ENV" => "production", "HOME" => mastodon_path + environment "RAILS_ENV" => "production", "HOME" => mastodon_path#, "SKIP_POST_DEPLOYMENT_MIGRATIONS" => "true" user mastodon_user group mastodon_user cwd mastodon_path From a0de016e1c6bb2fb8a2fbb1bb358ee5a3f015359 Mon Sep 17 00:00:00 2001 From: Sebastian Kippe Date: Sun, 5 Dec 2021 16:27:05 -0600 Subject: [PATCH 2/2] Add single sidekiq process for new scheduler queue --- .../kosmos-mastodon/recipes/default.rb | 16 ++++++++++++++++ ...stodon-sidekiq-scheduler.systemd.service.erb | 17 +++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 site-cookbooks/kosmos-mastodon/templates/default/mastodon-sidekiq-scheduler.systemd.service.erb diff --git a/site-cookbooks/kosmos-mastodon/recipes/default.rb b/site-cookbooks/kosmos-mastodon/recipes/default.rb index e37d03b..ccb999d 100644 --- a/site-cookbooks/kosmos-mastodon/recipes/default.rb +++ b/site-cookbooks/kosmos-mastodon/recipes/default.rb @@ -77,6 +77,18 @@ template "/lib/systemd/system/mastodon-sidekiq.service" do notifies :restart, "service[mastodon-sidekiq]", :delayed end +# mastodon-sidekiq-scheduler service +# +template "/lib/systemd/system/mastodon-sidekiq-scheduler.service" do + source "mastodon-sidekiq-scheduler.systemd.service.erb" + variables user: mastodon_user, + app_dir: mastodon_path, + bundle_path: "/opt/ruby_build/builds/#{ruby_version}/bin/bundle", + sidekiq_threads: 1 + notifies :run, "execute[systemctl daemon-reload]", :immediately + notifies :restart, "service[mastodon-sidekiq-scheduler]", :delayed +end + # mastodon-streaming service # template "/lib/systemd/system/mastodon-streaming.service" do @@ -176,6 +188,10 @@ application mastodon_path do action [:enable, :start] end + service "mastodon-sidekiq-scheduler" do + action [:enable, :start] + end + service "mastodon-streaming" do action [:enable, :start] end diff --git a/site-cookbooks/kosmos-mastodon/templates/default/mastodon-sidekiq-scheduler.systemd.service.erb b/site-cookbooks/kosmos-mastodon/templates/default/mastodon-sidekiq-scheduler.systemd.service.erb new file mode 100644 index 0000000..238855d --- /dev/null +++ b/site-cookbooks/kosmos-mastodon/templates/default/mastodon-sidekiq-scheduler.systemd.service.erb @@ -0,0 +1,17 @@ +[Unit] +Description=mastodon-sidekiq-scheduler +Requires=redis-server.service +After=redis-server.service + +[Service] +Type=simple +User=<%= @user %> +WorkingDirectory=<%= @app_dir %> +Environment="RAILS_ENV=production" +Environment="LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libjemalloc.so.1" +ExecStart=<%= @bundle_path %> exec sidekiq -c <%= @sidekiq_threads %> -q scheduler +TimeoutSec=15 +Restart=always + +[Install] +WantedBy=multi-user.target