]> cat aescling's git repositories - mastodon.git/commitdiff
Include capistrano tasks that reload the services after deploying. (#12642)
authorBèr Kessels <ber@berk.es>
Sun, 10 May 2020 08:19:49 +0000 (10:19 +0200)
committerGitHub <noreply@github.com>
Sun, 10 May 2020 08:19:49 +0000 (10:19 +0200)
After a successfull deploy, I need the services to switch over to use the
new code. I need to restart the services.

These capistrano tasks do that.

config/deploy.rb

index 31d14227536dca08098dc605fa38be1ecd8c0d26..76e6b281586a6fe6f18cb3d583f4bfd25c070f3d 100644 (file)
@@ -12,3 +12,21 @@ set :migration_role, :app
 
 append :linked_files, '.env.production', 'public/robots.txt'
 append :linked_dirs, 'vendor/bundle', 'node_modules', 'public/system'
+
+namespace :systemd do
+  %i[sidekiq streaming web].each do |service|
+    %i[reload restart status].each do |action|
+      desc "Perform a #{action} on #{service} service"
+      task "#{service}:#{action}".to_sym do
+        on roles(:app) do
+          # runs e.g. "sudo restart mastodon-sidekiq.service"
+          sudo :systemctl, action, "#{fetch(:application)}-#{service}.service"
+        end
+      end
+    end
+  end
+end
+
+after 'deploy:publishing', 'systemd:web:reload'
+after 'deploy:publishing', 'systemd:sidekiq:restart'
+after 'deploy:publishing', 'systemd:streaming:restart'