recipes/nginx.rake in peony-0.1.9 vs recipes/nginx.rake in peony-0.3.0
- old
+ new
@@ -1,49 +1,51 @@
-set_default :nginx, ->{ '/usr/local/bin/nginx' }
-set_default :nginx_home, ->{ `brew --prefix nginx`.strip }
-set_default :nginx_etc_dir, ->{ "#{etc_dir}/nginx" }
-set_default :nginx_run_dir, ->{ "#{run_dir}/nginx" }
-set_default :nginx_prefix, ->{ "#{log_dir}/nginx" }
+scope :nginx do
+ set_default :bin, ->{ '/usr/local/bin/nginx' }
+ set_default :home, ->{ `brew --prefix nginx`.strip }
+ set_default :etc_dir, ->{ "#{etc_dir}/nginx" }
+ set_default :run_dir, ->{ "#{run_dir}/nginx" }
+ set_default :prefix, ->{ "#{log_dir}/nginx" }
-set_default :worker_processes, 8
-
-set_default :upstreams, [
- {name: :fastcgi_server, servers: ['127.0.0.1:6666']},
- {name: :catalina_server, servers: ['127.0.0.1:8080']}
-]
+ set_default :worker_processes, 8
-set_default :server_name, 'localhost'
+ set_default :upstreams, [
+ {name: :fastcgi_server, servers: ['127.0.0.1:6666']},
+ {name: :catalina_server, servers: ['127.0.0.1:8080']}
+ ]
-set_default :use_ssl, false
-set_default :ssl_certificate, ->{"#{etc_dir}/ssl/server.crt"}
-set_default :ssl_certificate_key, ->{"#{etc_dir}/ssl/server.key"}
+ set_default :server_name, 'localhost'
+ set_default :use_ssl, true
+ set_default :ssl_certificate, ->{"#{etc_dir}/ssl/server.crt"}
+ set_default :ssl_certificate_key, ->{"#{etc_dir}/ssl/server.key"}
+end
def nginx_start_cmd(name)
- "#{nginx} -c #{nginx_etc_dir}/#{name}.conf -p #{nginx_prefix}"
+ "#{nginx.bin} -c #{nginx.etc_dir}/#{name}.conf -p #{nginx.prefix}"
end
def nginx_stop_cmd(name)
- "#{nginx} -s quit -c #{nginx_etc_dir}/#{name}.conf -p #{nginx_prefix}"
+ "#{nginx.bin} -s quit -c #{nginx.etc_dir}/#{name}.conf -p #{nginx.prefix}"
end
def nginx_reload_cmd(name)
- "#{nginx} -s reload -c #{nginx_etc_dir}/#{name}.conf -p #{nginx_prefix}"
+ "#{nginx.bin} -s reload -c #{nginx.etc_dir}/#{name}.conf -p #{nginx.prefix}"
end
def nginx_restart(name)
+ say_status :restart, 'restart nginx', :green
invoke "nginx:#{name}:stop"
- puts 'Start nginx......'
+ say 'Start nginx......', :yellow
sleep 5
invoke "nginx:#{name}:start"
end
namespace :nginx do
desc "Initialize nginx directory and create it's config files."
task :init do
- mkdir_p(nginx_etc_dir, nginx_run_dir, nginx_prefix, nginx_log_dir)
- unless File.exists?("#{nginx_etc_dir}/conf")
- FileUtils.cp_r(find_templates("nginx/conf", false).first, nginx_etc_dir)
+ mkdir_p(nginx.etc_dir, nginx.run_dir, nginx.prefix)
+ unless File.exists?("#{nginx.etc_dir}/conf")
+ FileUtils.cp_r(find_templates("nginx/conf", false).first, nginx.etc_dir)
end
- FileUtils.mkdir_p("#{nginx_etc_dir}/sites-enabled") unless File.exists?("#{nginx_etc_dir}/sites-enabled")
+ FileUtils.mkdir_p("#{nginx.etc_dir}/sites-enabled") unless File.exists?("#{nginx.etc_dir}/sites-enabled")
end
end