开发者

Capistrano 'reaper not found'

开发者 https://www.devze.com 2023-01-07 03:20 出处:网络
I\'m new to deploying with Capistrano, and I\'m trying the following: deploy.rb: set :application, \"example.co.uk\"

I'm new to deploying with Capistrano, and I'm trying the following:

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开发者_StackOverflow中文版 :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 

I get the following output:

  * 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

The "james" user can sudo. If I take out :use_sudo, I get the following error:

  * 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

I'm obviously missing something completely, as Google only seems to turn up old results about this.


There must have been a problem with the recipes, the following override works fine:

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


For people who encounter the same issue, have a glance to :

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

When calling the "cap deploy" command, "update" + "restart" in the "deploy" namespace are called.

Default behaviour for "restart" is to call the "script/process/reaper" script under the current path. In James's answer, "restart" is overridden with the below command :

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

For example, people using unicorn should process like :

  #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

Hope my contribution will be helpful to someone...

0

精彩评论

暂无评论...
验证码 换一张
取 消