尝试在Capistrano上部署3.我正在使用NGINX,RVM,Passenger,Rails 4.我的部署正在运行,但我需要手动重启NGINX - 这是部署结束时的错误:
DEBUG [c4e821bc] Command: ~/.rvm/bin/rvm default do passenger -v
DEBUG [c4e821bc] Phusion Passenger version 5.0.6
DEBUG [c4e821bc]
DEBUG [c4e821bc] "Phusion Passenger" is a trademark of Hongli Lai & Ninh Bui.
DEBUG [c4e821bc] Finished in 0.981 seconds with exit status 0 (successful).
INFO [5082ae94] Running ~/.rvm/bin/rvm default do passenger-config restart-app /home/deploy/skilltry --ignore-app-not-running on 104.237.158.232
DEBUG [5082ae94] Command: ~/.rvm/bin/rvm default do passenger-config restart-app /home/deploy/skilltry --ignore-app-not-running
DEBUG [5082ae94] *** ERROR: You are not authorized to query the status for this Phusion Passenger instance. Please try again with 'rvmsudo'.
cap aborted!
我在这里尝试过修复: https://github.com/capistrano/passenger/issues/2
Use visudo to edit the file (so if you mess up you have the chance to re-edit the file), at the end of the file (*) add the following:
deployuser ALL=(root) NOPASSWD: /usr/bin/passenger-config
这没什么区别
在这里: How can I get passenger-config restart-app to work?
但是我得到一个我无法进入的提示:
[sudo] password for deploy:
答案 0 :(得分:2)
查看gems / capistrano-passenger-0.0.5 / lib / capistrano / tasks / passenger.cap文件,它包含以下默认值:
task :defaults do
set :passenger_roles, :app
set :passenger_restart_runner, :sequence
set :passenger_restart_wait, 5
set :passenger_restart_limit, 2
set :passenger_restart_with_sudo, false
set :passenger_environment_variables, {}
set :passenger_restart_command, 'passenger-config restart-app'
set :passenger_restart_options, -> { "#{deploy_to} --ignore-app-not-running" }
set :passenger_rvm_ruby_version, ->{ fetch(:rvm_ruby_version) }
if Rake.application.tasks.collect(&:to_s).include?("rvm:hook")
before :'rvm:hook', :'passenger:rvm:hook'
end
if Rake.application.tasks.collect(&:to_s).include?("rbenv:map_bins")
before :'rbenv:map_bins', :'passenger:rbenv:hook'
end
end
我能够将以下内容添加到deploy.rb以覆盖乘客实例的重启方式:
set :passenger_restart_command, 'sudo passenger-config restart-app'
您应首先验证/ etc / sudoers配置是否允许以root身份执行该命令的无密码执行。
答案 1 :(得分:2)
当我尝试部署时,我也遇到了*** ERROR: You are not authorized to query the status for this Phusion Passenger instance. Please try again with 'sudo'.
错误。我发现使用了capistrano-passenger宝石,可以选择解决这个问题:
# add this to config/deploy.rb
set :passenger_restart_with_sudo, true # default false
您可以阅读docs以查看其他选项。
答案 2 :(得分:0)
Passenger是“进程管理器”,使用Nginx来管理往返于这些进程的http流量。
确保您的虚拟服务器指向Capistrano用户拥有的目录,并且虚拟服务器正在侦听Capistrano配置中存在的同一域。
假设您要部署到/home/my_user/my_app_path
,则应将my_user
设置为Capistrano用户以部署应用程序。
还要假设您的域为my_app.com
,请确保Capistrano和Nginx配置均一致。
# Capistrano configuration
server "my_app.com", user: "my_user", roles: %w{app web db}
# Nginx configuration
server {
listen 80;
server_name my_app.com;
root /home/my_user/my_app_path/current/public;
passenger_ruby /home/my_user/.rbenv/shims/ruby;
passenger_enabled on;
passenger_min_instances 2;
passenger_max_requests 5000;
rails_env production;
#... some more config settings
}
passenger_pre_start http://my_app.com;