lib/capistrano/tasks/nginx-unit.rake in capistrano-nginx-unit-0.4.1 vs lib/capistrano/tasks/nginx-unit.rake in capistrano-nginx-unit-0.4.2
- old
+ new
@@ -60,19 +60,19 @@
end
end
desc "Attach application configuration to NGINX Unit"
task :attach_app do
- on release_roles(fetch(:nginx_unit_roles)) do |role|
+ on release_roles(fetch(:nginx_unit_roles)) do
released_dir = capture(:readlink, "-f", current_path)
raise "Doesn't exist released dir: #{released_dir}" unless test("[ -d #{released_dir} ]")
app_json = JSON.generate({
type: "ruby",
processes: fetch(:nginx_unit_processes),
- user: fetch(:nginx_unit_user) || role.user,
- group: fetch(:nginx_unit_group) || role.user,
+ user: fetch(:nginx_unit_user) || host.user,
+ group: fetch(:nginx_unit_group) || host.user,
working_directory: fetch(:nginx_unit_working_dir),
script: File.join(released_dir, fetch(:nginx_unit_script))
}.compact)
control_nginx_unit(:put, path: "/applications/#{fetch(:nginx_unit_app_name)}", json: app_json)
@@ -112,18 +112,24 @@
end
# Send request to NGINX Unit control socket
def control_nginx_unit(method, path: "", json: nil)
args = [
- "-fs",
+ "-s",
"-X #{method.to_s.upcase}",
"--unix-socket #{fetch(:nginx_unit_control_sock)}",
"'http://localhost/#{path}'"
]
args << "-d '#{json}'" if json
- execute :curl, *args
+ res = JSON.parse(capture(:curl, *args))
+ if res["error"]
+ error res.inspect
+ raise "NGINX Unit: #{res["error"]}"
+ else
+ info res.inspect
+ end
end
# Get current configuration
def nginx_unit_conf
JSON.parse(capture(