Skip to content

Instantly share code, notes, and snippets.

@erpe
Created August 13, 2018 14:50
Show Gist options
  • Save erpe/5e9ff5f976b9c1a9b0a73c88c40c4c65 to your computer and use it in GitHub Desktop.
Save erpe/5e9ff5f976b9c1a9b0a73c88c40c4c65 to your computer and use it in GitHub Desktop.
Simple 'start-stop-daemon'-based script to start/stop/restart kemal after deployment with capistrano
namespace :deploy do
desc 'show kemal status'
task :kemal_status do
on roles(:app) do
within "#{release_path}" do
execute "start-stop-daemon",
"-v",
"--status",
"--pid",
"`cat #{shared_path}/tmp/pids/kemal.pid`"
end
end
end
desc 'stop kemal'
task :kemal_stop do
on roles(:app) do
within "#{release_path}" do
execute "start-stop-daemon",
"-v",
"--stop",
"--pid",
"`cat #{shared_path}/tmp/pids/kemal.pid`"
end
end
end
desc 'start_kemal'
task :kemal_start do
on roles(:app) do
within "#{release_path}" do
execute "start-stop-daemon",
"-v",
"--start",
"--make-pidfile",
"--background",
"--pidfile",
"#{shared_path}/tmp/pids/kemal.pid",
"--exec",
"#{current_path}/app",
"--",
"-p3030"
end
end
end
desc 'restart_kemal'
task :kemal_restart do
invoke 'deploy:kemal_stop'
invoke 'deploy:kemal_start'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment