lib/capistrano/tasks/nginx-unit.rake in capistrano-nginx-unit-0.1 vs lib/capistrano/tasks/nginx-unit.rake in capistrano-nginx-unit-0.2
- old
+ new
@@ -1,23 +1,41 @@
namespace :load do
task :defaults do
set :nginx_unit_roles, -> { :app }
+ set :nginx_unit_pid, -> { "/var/run/unit.pid" }
set :nginx_unit_control_sock, -> { "/var/run/control.unit.sock" }
+ set :nginx_unit_options, -> { "" }
set :nginx_unit_listen, -> { "*:3000" }
set :nginx_unit_app_name, -> { fetch(:application) }
set :nginx_unit_processes, -> { 1 }
set :nginx_unit_user, -> { nil }
set :nginx_unit_group, -> { nil }
set :nginx_unit_script, -> { "config.ru" }
end
end
-# TODO: Start and stop NGINX Unit process
+# TODO: Stop NGINX Unit process
namespace :nginx_unit do
+ desc "Start NGINX Unit process"
+ task :start do
+ on release_roles(fetch(:nginx_unit_roles)) do
+ pid_file = fetch(:nginx_unit_pid)
+ if test("[ -e #{pid_file} ] && kill -0 `cat #{pid_file}`")
+ info "NGINX Unit is already started"
+ else
+ execute :sudo, :unitd,
+ "--pid #{pid_file}",
+ "--control unix:#{fetch(:nginx_unit_control_sock)}",
+ fetch(:nginx_unit_options)
+ end
+ end
+ end
+
# If you want to apply new code when deployed,
# please invoke this task after deploy:published
desc "Set listener and application configuration for NGINX Unit"
task :configure do
+ invoke "nginx_unit:start"
invoke "nginx_unit:configure_app"
invoke "nginx_unit:configure_listener"
end
desc "Set listener configuration for NGINX Unit"