lib/capistrano/tasks/runit.rake in capistrano-monit_runit-3.0.0 vs lib/capistrano/tasks/runit.rake in capistrano-monit_runit-3.0.1
- old
+ new
@@ -34,10 +34,11 @@
namespace :runit do
desc 'Get the config needed to add to sudoers for all commands'
task :sudoers do
run_locally do
info '---------------ENTRIES FOR SUDOERS (Runit)---------------------'
+ puts "# Sudo runit entries for #{fetch(:application)}"
puts "#{fetch(:user)} ALL=NOPASSWD: /bin/mkdir -p #{runit_user_base_path}"
puts "#{fetch(:user)} ALL=NOPASSWD: /bin/chown #{fetch(:user)}\\:root #{runit_user_base_path}"
puts "#{fetch(:user)} ALL=NOPASSWD: /bin/chmod 6775 #{runit_user_base_path}"
puts "#{fetch(:user)} ALL=NOPASSWD: /bin/mkdir -p #{runit_etc_service_path}"
puts "#{fetch(:user)} ALL=NOPASSWD: /bin/chown #{fetch(:user)}\\:root #{runit_etc_service_path}"
@@ -69,20 +70,17 @@
# '[INTERNAL] create /etc/sv folders and upload base templates needed'
task :runit_create_app_services do
on roles(:app) do |host|
# set :pw, ask("Sudo password", '')
# execute :echo, "#{fetch(:pw)} | sudo -S ls /"
- if test("[ ! -d '#{runit_user_base_path}' ]")
- execute :sudo, :mkdir, "-p '#{runit_user_base_path}'"
- execute :sudo, :chown, "#{fetch(:user)}:root '#{runit_user_base_path}'"
- execute :sudo, :chmod, "6775 '#{runit_user_base_path}'"
- end
- if test("[ ! -d '#{runit_etc_service_path}' ]")
- execute :sudo, :mkdir, "-p '#{runit_etc_service_path}'"
- execute :sudo, :chown, "#{fetch(:user)}:root '#{runit_etc_service_path}'"
- execute :sudo, :chmod, "6775 '#{runit_etc_service_path}'"
- end
+ execute :sudo, :mkdir, "-p '#{runit_user_base_path}'" if test("[ ! -d '#{runit_user_base_path}' ]")
+ execute :sudo, :chown, "#{fetch(:user)}:root '#{runit_user_base_path}'"
+ execute :sudo, :chmod, "6775 '#{runit_user_base_path}'"
+
+ execute :sudo, :mkdir, "-p '#{runit_etc_service_path}'" if test("[ ! -d '#{runit_etc_service_path}' ]")
+ execute :sudo, :chown, "#{fetch(:user)}:root '#{runit_etc_service_path}'"
+ execute :sudo, :chmod, "6775 '#{runit_etc_service_path}'"
within("#{runit_user_base_path}") do
execute :mkdir, "-p #{app_env_folder}"
end
upload! template_to_s_io(fetch(:runit_run_template)), runit_run_file
@@ -111,10 +109,17 @@
execute :chmod, "775 '#{runit_log_run_file}'"
info "RUNIT: Created inital runit log services in #{runit_base_log_path} for #{fetch(:application)} on #{host}"
end
end
+ # '[INTERNAL] create /etc/sv folders and upload base templates needed'
+ task :runit_ensure_shared_sockets_and_pids_folders do
+ on roles(:app) do |host|
+ execute :mkdir, fetch(:pids_path) if test("[ ! -d #{fetch(:pids_path)} ]")
+ execute :mkdir, fetch(:sockets_path) if test("[ ! -d #{fetch(:sockets_path)} ]")
+ end
+ end
end
desc 'Disable runit services for application'
task :disable do
on roles(:app) do |host|
@@ -146,27 +151,23 @@
execute :rm, "-rf #{runit_base_path}"
info "RUNIT purging config on '#{host}'"
end
end
- desc 'Stop all runit services for current application'
- task :stop do
- runit_app_services_control('stop')
+ %w(stop start once restart).each do |single_cmd|
+ desc "#{single_cmd} runit services for application"
+ task single_cmd.to_sym do
+ on roles(:app) do |host|
+ info "RUNIT: #{single_cmd} on #{host}"
+ runit_app_services_control(single_cmd)
+ end
+ end
end
-
- desc 'Start all runit services for current application'
- task :start do
- runit_app_services_control('start')
- end
-
- desc 'Only start services once. Will not restart if they fail.'
- task :once do
- runit_app_services_control('once')
- end
end
before 'runit:purge', 'runit:stop'
after 'deploy:updated', 'runit:enable'
# after 'deploy:setup', 'runit:setup'
after 'runit:setup', 'runit:setup:runit_create_app_services'
after 'runit:setup:runit_create_app_services', 'runit:setup:runit_create_app_log_services'
+after 'runit:setup:runit_create_app_services', 'runit:setup:runit_ensure_shared_sockets_and_pids_folders'