我目前正在设置一个生产环境,让工头和capistrano玩得很好时遇到了一些问题。
所有让foreman将其任务导出到upstart的示例都需要使用root权限,目前我没有使用root或sudo来执行我的部署。
问题是foreman似乎需要root权限才能导出。正在部署的THe用户具有根权限,但是我不想使用sudo运行与工头相关的任何命令。有没有一种方法可以像这样设置
set :use_sudo, true但仅限于与工头相关的任务?
或者,有没有办法让foreman在不使用sudo的情况下出口到初创公司?
如果知道机器正在运行Ubuntu 12.04,并且可以在服务器上访问foreman,这会有所帮助
编辑
我的Deploy.rb的配置
require "bundler/capistrano"
require "rvm/capistrano"
set :rvm_ruby_string, :local # use the same ruby as used
set :rvm_autolibs_flag, "read-only" # more info: rvm help autolibs
before 'deploy', 'rvm:install_rvm' # install RVM
server "ip_to_server", :web, :app, :db, primary: true
set :application, "app_name"
set :user, "deploy_user"
set :deploy_to, "/home/#{user}/apps/#{application}"
set :deploy_via, :remote_cache
set :use_sudo, false
set :scm, "git"
set :repository, "repo_path"
set :branch, "production"
default_run_options[:pty] = true
ssh_options[:forward_agent] = true我的foreman命名空间如下所示
namespace :foreman do
desc 'Export the Procfile to Ubuntu upstart scripts'
task :export, :roles => :app do
run "cd #{release_path} && sudo bundle exec foreman export upstart
/etc/init -a #{application} -u #{user} -l #{release_path}/log/foreman -f
#{current_path}/Procfile"
end
desc "Start the application services"
task :start, :roles => :app do
sudo "start #{application}"
end
desc "Stop the application services"
task :stop, :roles => :app do
sudo "stop #{application}"
end
desc "Restart the application services"
task :restart, :roles => :app do
run "sudo start #{application} || sudo restart #{application}"
end
endexport命令会触发并留下以下内容
正在执行命令** out ::server_ip password for deploy
没有办法输入
发布于 2013-05-27 12:26:14
使用命令禁用use_sudo并添加sudo。
例如:
set :use_sudo, false
task :foreman do
run "sudo foreman export upstart /etc/init -f Procfile"
endhttps://stackoverflow.com/questions/16766108
复制相似问题