diff --git a/lib/capistrano/tasks/nginx.rake b/lib/capistrano/tasks/nginx.rake index abdcd5d..186cbfc 100644 --- a/lib/capistrano/tasks/nginx.rake +++ b/lib/capistrano/tasks/nginx.rake @@ -26,6 +26,9 @@ namespace :load do set :nginx_ssl_cert_key_local_path, -> { ask(:nginx_ssl_cert_key_local_path, 'Local path to ssl certificate key: ') } set :nginx_fail_timeout, 0 # see http://nginx.org/en/docs/http/ngx_http_upstream_module.html#fail_timeout set :nginx_read_timeout, nil + + set :nginx_log_path, nil + set :nginx_log_level, 'debug' set :linked_dirs, fetch(:linked_dirs, []).push('log') end diff --git a/lib/generators/capistrano/unicorn_nginx/templates/_default_server_directive.erb b/lib/generators/capistrano/unicorn_nginx/templates/_default_server_directive.erb index d7052e7..35ecedd 100644 --- a/lib/generators/capistrano/unicorn_nginx/templates/_default_server_directive.erb +++ b/lib/generators/capistrano/unicorn_nginx/templates/_default_server_directive.erb @@ -43,6 +43,12 @@ server { error_page 500 502 504 /500.html; error_page 503 @503; +<% if fetch(:nginx_log_path) -%> + access_log <%= fetch(:nginx_log_path) %>/nginx_access.log combined + error_log <%= fetch(:nginx_log_path) %>/nginx_error.log <%= fetch(:nginx_log_level) %> +<% end -%> + + server_name <%= fetch(:nginx_server_name) %>; root <%= current_path %>/public; try_files $uri/index.html $uri @unicorn_<%= fetch(:nginx_config_name) %>;