lib/capistrano/tasks/nginx.rake in capistrano3-nginx-2.0.1 vs lib/capistrano/tasks/nginx.rake in capistrano3-nginx-2.0.2
- old
+ new
@@ -1,15 +1,20 @@
namespace :load do
task :defaults do
+ set :nginx_service_path, -> { 'service nginx' }
set :nginx_roles, -> { :web }
set :nginx_log_path, -> { "#{shared_path}/log" }
set :nginx_root_path, -> { "/etc/nginx" }
set :nginx_static_dir, -> { "public" }
set :nginx_sites_enabled, -> { "sites-enabled" }
set :nginx_sites_available, -> { "sites-available" }
set :nginx_template, -> { :default }
set :nginx_use_ssl, -> { false }
+ set :nginx_ssl_certificate, -> { "#{fetch(:application)}.crt" }
+ set :nginx_ssl_certificate_path, -> { '/etc/ssl/certs' }
+ set :nginx_ssl_certificate_key, -> { "#{fetch(:application)}.crt" }
+ set :nginx_ssl_certificate_key_path, -> { '/etc/ssl/private' }
set :app_server, -> { true }
end
end
namespace :nginx do
@@ -21,12 +26,13 @@
end
%w[start stop restart reload].each do |command|
desc "#{command.capitalize} nginx service"
task command do
+ nginx_service = fetch(:nginx_service_path)
on release_roles fetch(:nginx_roles) do
- if command === 'stop' || (test "sudo nginx -t")
- execute :sudo, "service nginx #{command}"
+ if command === 'stop' || (test "[ $(sudo #{nginx_service} configtest | grep -c 'fail') -eq 0 ]")
+ execute :sudo, "#{nginx_service} #{command}"
end
end
end
end