我正在使用capistrano部署我的Rails 3应用程序。
我已经将用户(部署)添加到了sudoers。这是我正在部署的用户。
当我以部署方式登录服务器时,我可以访问我需要的所有gem命令.ie:bundle,等等。
Capistrano似乎以sudo的形式运行,当我尝试时:
sudo whenever
我得到了
sudo: whenever: command not found
这意味着每次尝试部署时,都会失败并回滚。
我在deploy.rb文件中尝试设置:use_sudo为false,但仍然没有运气
set :user, "deploy"
set :runner, user
set :use_sudo, false
有什么建议吗?
这是我的完整部署脚本,以防我遗漏了任何内容:
require 'config/boot'
require 'hoptoad_notifier/capistrano'
require 'capistrano/ext/multistage'
require "whenever/capistrano"
#
set :whenever_command, "bundle exec whenever"
set :application, "MYAPP"
set :repository, "git@github.com:myAccount/myRepos.git"
# only keep 3 previous releases after cleanup
set :keep_releases, 3
set :scm, "git"
set :scm_user, "me"
set :branch, lambda {rails_env}
set :deploy_to, lambda {"/var/www/#{application}/#{rails_env}"}
default_run_options[:pty] = true
role :web, "xxx.xxx.xxx.xxx" # Your HTTP server, Apache/etc
role :app, "xxx.xxx.xxx.xxx" # This may be the same as your `Web` server
role :db, "xxx.xxx.xxx.xxx", :primary => true # This is where Rails migrations will run
set :user, "deploy"
set :runner, user
set :use_sudo, false
ssh_options[:paranoid] = false
ssh_options[:port] = 22
namespace :deploy do
task :start do ; end
task :stop do ; end
task :restart, :roles => :app do
run " touch #{File.join(current_path,'tmp','restart.txt')}"
end
end
namespace :bundle do
desc "run bundle install"
task :install do
run "cd #{current_release} && bundle install"
end
end
namespace :tail do
desc "Tail the current environment's log file"
task :log, :roles => :app do
stream "tail -f #{shared_path}/log/#{rails_env}.log"
end
desc "Tail the new relic log file"
task :new_relic, :roles => :app do
stream "tail -f #{shared_path}/log/new_relic.log"
end
end
before "deploy:restart", "bundle:install"
after "deploy:restart", "deploy:cleanup"
after "deploy:restart", "whenever:update_crontab"
答案 0 :(得分:4)
在服务器上运行which whenever
或whereis whenever
您应该获得将命令放入脚本的完整路径:
set :whenever_command, "path_to-whenever"
这不是干净的解决方案,但可能有用。
另一个解决方案可能是sudo重新配置,转到/etc/sudoers
并查看env_keep
添加PATH
可能非常重要,以保留所有重要的应用程序,您可以使用rvm ,capistrano-rvm集成并将所有显示的变量从rvm info
放到env_keep,理论上它应该可以工作,只要小心不要弄乱任何东西