diff --git a/site-cookbooks/kosmos-mastodon/recipes/deploy.rb b/site-cookbooks/kosmos-mastodon/recipes/deploy.rb index aebac8f..9574eea 100644 --- a/site-cookbooks/kosmos-mastodon/recipes/deploy.rb +++ b/site-cookbooks/kosmos-mastodon/recipes/deploy.rb @@ -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"