[英]Rails Capistrano and Foreman
I am currently setting up a production environment and have had some issue getting foreman playing nice with capistrano. 我目前正在建立生产环境,在让工头与capistrano融洽相处时遇到了一些问题。
All examples of having foreman export its tasks to upstart have required the use of root privileges and currently I am not using a root or sudo to execute my deploy. 让领班将其任务导出到新贵的所有示例都需要使用root特权,并且目前我不使用root或sudo来执行我的部署。
Issue is it seems foreman requires root privileges to export. 问题是工头似乎需要root特权才能导出。 THe user that is deploying has root privileges however I do not want to run anything but the foreman related commands with sudo. 正在部署的用户具有root特权,但是除了sudo的与领班相关的命令外,我不想运行任何东西。 Is there a way to set something like 有没有办法设置类似
set :use_sudo, true
but only for foreman related tasks? 但仅用于领班相关的任务吗?
or is there a way to get foreman to export to upstart without the use of sudo? 还是有一种方法可以使领班不使用sudo导出到新贵?
If it helps to know the box is running Ubuntu 12.04 with foreman accessible on the server 如果有助于了解该框正在运行Ubuntu 12.04,并且可以在服务器上访问工头
EDIT 编辑
The configs for my Deploy.rb 我的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
My foreman namespace looks like this 我的领班命名空间看起来像这样
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
end
The command to export fires off and leaves me with this 出口的命令被解雇了
executing command ** [out :: server_ip] [sudo] password for deploy 执行命令** [out :: server_ip] [sudo]部署密码
wih no way to input 没有办法输入
Disable the use_sudo
and add the sudo
with the command. 禁用use_sudo
并使用命令添加sudo
。
For example: 例如:
set :use_sudo, false
task :foreman do
run "sudo foreman export upstart /etc/init -f Procfile"
end
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.