Declare the search deploy unit before the migration chain

The migration chain starts mastodon-search-deploy.service immediately, but the systemd_unit resource was declared later in the recipe, so the unit did not exist yet and systemctl failed with 'Unit not found'.
This commit is contained in:
raucao committed 2026-10-08 12:21:24 +02:00
1 parent af4983d747
commit 8ac0b965b2
1 file changed
+22 -24
@@ -94,6 +94,28 @@ execute "restart mastodon services" do
action :nothing
end
# Populate the Elasticsearch indices in the background. The indices and
# mappings are created synchronously during the deployment; this unit only does
# the (potentially very long) import, so it is started without blocking. Declared
# before the migration chain below because that chain starts it.
systemd_unit 'mastodon-search-deploy.service' do
content({
Unit: {
Description: 'Populate the Mastodon search index'
},
Service: {
Type: "oneshot",
User: mastodon_user,
WorkingDirectory: mastodon_path,
Environment: "RAILS_ENV=#{rails_env}",
ExecStart: "#{bundle_path} exec bin/tootctl search deploy",
TimeoutStartSec: "21600",
}
})
triggers_reload true
action [:create]
end
# Mastodon 4.4+ splits migrations into pre- and post-deployment phases.
# Pre-deployment migrations must run before the services are (re)started.
execute "rake db:migrate (pre-deployment)" do
@@ -203,30 +225,6 @@ systemd_unit 'mastodon-delete-old-media-cache.timer' do
action [:create, :enable, :start]
end
#
# Populate the Elasticsearch indices in the background. The indices and
# mappings are created synchronously by the recipe above; this unit only does
# the (potentially very long) import, so it is started without blocking.
#
systemd_unit 'mastodon-search-deploy.service' do
content({
Unit: {
Description: 'Populate the Mastodon search index'
},
Service: {
Type: "oneshot",
User: mastodon_user,
WorkingDirectory: mastodon_path,
Environment: "RAILS_ENV=#{rails_env}",
ExecStart: "#{bundle_path} exec bin/tootctl search deploy",
TimeoutStartSec: "21600",
}
})
triggers_reload true
action [:create]
end
firewall_rule "mastodon_app" do
port node['kosmos-mastodon']['app_port']
source "10.1.1.0/24"