Add support for legacy unicorn installations

Old CONSUL nginx configurations will probably have a reference to a
unicorn socket. Making that file a symbolic link to a puma socket makes
it possible for the application to keep working without updating the
nginx configuration file.
This commit is contained in:
Javi Martín
2019-10-12 17:00:46 +02:00
parent 3b79a1a3db
commit f26f8b3c3e

View File

@@ -50,6 +50,8 @@ namespace :deploy do
after :published, "delayed_job:restart"
after :published, "refresh_sitemap"
before "deploy:restart", "setup_puma"
after :finishing, "deploy:cleanup"
desc "Deploys and runs the tasks needed to upgrade to a new release"
@@ -94,3 +96,22 @@ task :execute_release_tasks do
end
end
end
desc "Create pid and socket folders needed by puma and convert unicorn sockets into symbolic links \
to the puma socket, so legacy nginx configurations pointing to the unicorn socket keep working"
task :setup_puma do
on roles(:app) do
with rails_env: fetch(:rails_env) do
execute "mkdir -p #{shared_path}/tmp/sockets; true"
execute "mkdir -p #{shared_path}/tmp/pids; true"
if test("[ -e #{shared_path}/tmp/sockets/unicorn.sock ]")
execute "ln -sf #{shared_path}/tmp/sockets/puma.sock #{shared_path}/tmp/sockets/unicorn.sock; true"
end
if test("[ -e #{shared_path}/sockets/unicorn.sock ]")
execute "ln -sf #{shared_path}/tmp/sockets/puma.sock #{shared_path}/sockets/unicorn.sock; true"
end
end
end
end