簡體   English   中英

Rails Capistrano和領班

[英]Rails Capistrano and Foreman

我目前正在建立生產環境,在讓工頭與capistrano融洽相處時遇到了一些問題。

讓領班將其任務導出到新貴的所有示例都需要使用root特權,並且目前我不使用root或sudo來執行我的部署。

問題是工頭似乎需要root特權才能導出。 正在部署的用戶具有root特權,但是除了sudo的與領班相關的命令外,我不想運行任何東西。 有沒有辦法設置類似

    set :use_sudo, true

但僅用於領班相關的任務嗎?

還是有一種方法可以使領班不使用sudo導出到新貴?

如果有助於了解該框正在運行Ubuntu 12.04,並且可以在服務器上訪問工頭

編輯

我的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

我的領班命名空間看起來像這樣

    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

出口的命令被解雇了

執行命令** [out :: server_ip] [sudo]部署密碼

沒有辦法輸入

禁用use_sudo並使用命令添加sudo

例如:

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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM