没有找到Capistrano的收割机

时间:2010-07-15 17:33:58

标签: ruby-on-rails capistrano

我刚接触Capistrano部署,我正在尝试以下方法:

deploy.rb:

set :application, "example.co.uk"

# If you aren't deploying to /u/apps/#{application} on the target
# servers (which is the default), you can specify the actual location
# via the :deploy_to variable:
set :deploy_to, "/home/example/#{application}"

# SCM Options
default_run_options[:pty] = true  # Must be set for the password prompt from git to work
ssh_options[:forward_agent] = true # Agent forwarding keys
set :repository, "git@github.com:mongeese/example.git"  # Your clone URL
set :scm, "git"
set :branch, "master"
set :deploy_via, :remote_cache
set :user, "james"  # The server's user for deploys

role :app, "example.co.uk"
role :web, "example.co.uk"
role :db,  "example.co.uk", :primary => true

set :use_sudo, false 

我得到以下输出:

  * executing `deploy:restart'
  * executing "/home/example/example.co.uk/current/script/process/reaper"
    servers: ["example.co.uk"]
    [example.co.uk] executing command
 ** [out :: example.co.uk] sh: /home/example/example.co.uk/current/script/process/reaper: not found
    command finished

“詹姆斯”用户可以sudo。如果我拿出:use_sudo,我收到以下错误:

  * executing "sudo -p 'sudo password: ' -u app /home/example/example.co.uk/current/script/process/reaper"
    servers: ["example.co.uk"]
    [example.co.uk] executing command
 ** [out :: example.co.uk] sudo: unknown user: app
    command finished

我显然完全错过了一些东西,因为谷歌似乎只是发现了旧的结果。

2 个答案:

答案 0 :(得分:1)

配方一定存在问题,以下覆盖工作正常:

set :application, "example.co.uk"

# If you aren't deploying to /u/apps/#{application} on the target
# servers (which is the default), you can specify the actual location
# via the :deploy_to variable:
set :deploy_to, "/home/example/#{application}"

# SCM Options
default_run_options[:pty] = true  # Must be set for the password prompt from git to work
ssh_options[:forward_agent] = true # Agent forwarding keys
set :repository, "git@github.com:example/MyRepo.git"  # Your clone URL
set :scm, "git"
set :branch, "master"
set :deploy_via, :remote_cache
set :user, "james"  # The server's user for deploys

role :app, "example.co.uk"
role :web, "example.co.uk"
role :db,  "example.co.uk", :primary => true

namespace :deploy do
  desc "Restarting mod_rails with restart.txt"
  task :restart, :roles => :app, :except => { :no_release => true } do
    run "touch #{current_path}/tmp/restart.txt"
  end

  [:start, :stop].each do |t|
    desc "#{t} task is a no-op with mod_rails"
    task t, :roles => :app do ; end
  end
end

答案 1 :(得分:0)

对于遇到相同问题的人,请浏览:

http://capitate.rubyforge.org/recipes/deploy.html#deploy:restart

调用“cap deploy”命令时,会调用“deploy”命名空间中的“update”+“restart”。

“restart”的默认行为是在当前路径下调用“script / process / reaper”脚本。在James的回答中,“restart”被以下命令覆盖:

run "touch #{current_path}/tmp/restart.txt"

例如,使用unicorn的人应该像:

一样处理
  #launch unicorn
  task :start, roles: :app, except: { no_release: true } do
    run "cd #{current_path} && bundle exec unicorn_rails -c config/unicorn.rb -E #{rails_env} -D"
  end

  #stop unicorn
  task :stop, roles: :app, except: { no_release: true } do
    run "kill -KILL -s QUIT `cat #{shared_path}/pids/unicorn.pid`"
  end

  #when calling "cap deploy", files will be updated with #update# task (default behaviour),
  #then "restart" task will be called (overridden below)
  task :restart, roles: :app, except: { no_release: true } do
    stop
    start
  end

希望我的贡献对某人有所帮助......