2010-07-15 49 views
1

我是新來與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, "[email protected]: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 

「james」用戶可以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 

我顯然缺少的東西完全,因爲谷歌似乎只調高這個老的效果。

回答

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, "[email protected]: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 
0

對於誰遇到同樣問題的人,都一目瞭然:

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

當調用「cap deploy」命令,在「deploy」命名空間中調用「update」+「restart」命令。

「restart」的默認行爲是調用當前路徑下的「script/process/reaper」腳本。在詹姆斯的回答,「重啓」被覆蓋與下面的命令:

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 

希望我的貢獻將有助於有人...