# Capistrano restarts wrong release

**URL:** <https://www.ruby-forum.com/t/capistrano-restarts-wrong-release/134251>\
**Category:** Deployment\
**Created:** [April 9, 2008, 9:23am UTC](https://www.ruby-forum.com/t/capistrano-restarts-wrong-release/134251 "2008-04-09T09:23:41Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![chrisjo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/a183cd/32.png) [@chrisjo](https://www.ruby-forum.com/u/chrisjo)\
**Post date:** [April 9, 2008, 9:23am UTC](https://www.ruby-forum.com/t/capistrano-restarts-wrong-release/134251/1 "2008-04-09T09:23:41Z")

</div>

I’m having some trouble where it seems that capistrano deploys just fine  
(with cap deploy), however, the site is never refreshed. After some  
checking it appears that capistrano in fact restarts the mongrels, but  
not for the current release?

This is the relevant piece from my config/deploy.rb:

task :restart, :roles =\> :app do

# stop mongrel clusters for previous release and start for current

run “cd #{previous\_release} && mongrel\_rails cluster::stop”  
run “sleep 5”  
run “cd #{current\_release} && mongrel\_rails cluster::start”  
end

Also, on the server script/process/reaper seems to restart an old  
release as well. Anyone seen this?

---

<div class="post-metadata">

**Author:** ![chrisjo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/a183cd/32.png) [@chrisjo](https://www.ruby-forum.com/u/chrisjo)\
**Post date:** [April 10, 2008, 12:31pm UTC](https://www.ruby-forum.com/t/capistrano-restarts-wrong-release/134251/2 "2008-04-10T12:31:27Z")

</div>

Mongrel configuration exists when do restart task? Any log?

If you didn’t wants play with previous and current release, you can use  
shared path to maintain pids and configurations beetwen releases.

Regards

Christian J. escribiÃ³:

> run “sleep 5”  
> run “cd #{current\_release} && mongrel\_rails cluster::start”  
> end
> 
> Also, on the server script/process/reaper seems to restart an old  
> release as well. Anyone seen this?

–  
Rafael Garcia Ortega

---

<div class="post-metadata">

**Author:** ![chrisjo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/a183cd/32.png) [@chrisjo](https://www.ruby-forum.com/u/chrisjo)\
**Post date:** [April 11, 2008, 1:46pm UTC](https://www.ruby-forum.com/t/capistrano-restarts-wrong-release/134251/3 "2008-04-11T13:46:27Z")

</div>

Does the mongrel processes pids change?

Would you post your whole cofing/deploy.rb file?

–  
AnibalRojas

> **[Home - Has Many Developers](https://hasmanydevelopers.com/)**
>
> We are the best choice for your building design and development

> **[RUBYCORNER.COM](https://www.rubycorner.com/)**
>
> RUBYCORNER.COM - Contact us for any business inquiries

[http://anibal.rojas.com.ve](http://anibal.rojas.com.ve)

On Apr 9, 3:23 am, Christian J. \<ruby-forum-incom…@andreas-

---

<div class="post-metadata">

**Author:** ![chrisjo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/a183cd/32.png) [@chrisjo](https://www.ruby-forum.com/u/chrisjo)\
**Post date:** [April 11, 2008, 2:04pm UTC](https://www.ruby-forum.com/t/capistrano-restarts-wrong-release/134251/4 "2008-04-11T14:04:28Z")

</div>

Thanks for your help. The mongrel pids do indeed change, but no change  
is visible on my webapp. This is my complete config/deploy.rb:

set :application, “myapp”  
set :repository, “[https://svn.myserver.com/repos/myapp/trunk](https://svn.myserver.com/repos/myapp/trunk)”

# 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, “/var/www/#{application}”

set :deploy\_to, “/var/www/mysite/#{application}”

set :user, “christian”

# If you aren’t using Subversion to manage your source code, specify

# your SCM below:

# set :scm, :subversion

role :app, “[myserver.com](http://myserver.com)”  
role :web, “[myserver.com](http://myserver.com)”  
role :db, “[myserver.com](http://myserver.com)”, :primary =\> true

task :restart, :roles =\> :app do

# stop mongrel clusters for previous release and start for current

run “cd #{previous\_release} && mongrel\_rails cluster::stop”  
run “sleep 5”  
run “cd #{current\_release} && mongrel\_rails cluster::start”  
end

# This fixed frustrating â€™sudo: no passwd entry for appâ€™ error when cap

was trying

# to run the process start command as â€˜appâ€™ for some reason

set :runner, ‘christian’

# Currently not using this

#task :copy\_database\_yml, :roles =\> :app do

# db\_config = “#{shared\_path}/config/database.yml.production”

# run “cp #{db\_config} #{release\_path}/config/database.yml”

#end

# 

#after “deploy:update\_code”, :copy\_database\_yml

AnÃ­bal Rojas wrote:

> Does the mongrel processes pids change?
> 
> Would you post your whole cofing/deploy.rb file?
> 
> –  
> AnibalRojas  
> [http://hasmanydevelopers.com](http://hasmanydevelopers.com)  
> [http://rubycorner.com](http://rubycorner.com)  
> [http://anibal.rojas.com.ve](http://anibal.rojas.com.ve)
> 
> On Apr 9, 3:23 am, Christian J. \<ruby-forum-incom…@andreas-

---

<div class="post-metadata">

**Author:** ![chrisjo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/a183cd/32.png) [@chrisjo](https://www.ruby-forum.com/u/chrisjo)\
**Post date:** [April 11, 2008, 3:15pm UTC](https://www.ruby-forum.com/t/capistrano-restarts-wrong-release/134251/5 "2008-04-11T15:15:41Z")

</div>

Jamis, thank you, now my restart task is running atleast. But now I  
have:

ERROR RUNNING ‘cluster::stop’: Plugin /cluster::stop does not exist in  
category /commands

so, I thought maybe I could change the task, but I don’t know which  
program to run to stop my three mongrels 🙂 I start the rascals using  
script/spin which contains:

#!/bin/sh  
script/process/spawner -a 127.0.0.1 -p 8000 -i 3

script/process/reaper only seems to restart, so I don’t really know what  
command to use to stop the old application, move to the new release  
folder and then start the servers again. Any ideas?

Jamis B. wrote:

> Note that the restart task needs to be in the deploy namespace:
> 
> namespace :deploy do  
> task :restart, :roles =\> :app do  
> # …  
> end  
> end
> 
> Otherwise, you’re not overriding deploy:restart, as you probably are  
> intending.
> 
> - Jamis

---

<div class="post-metadata">

**Author:** ![chrisjo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/a183cd/32.png) [@chrisjo](https://www.ruby-forum.com/u/chrisjo)\
**Post date:** [April 11, 2008, 3:02pm UTC](https://www.ruby-forum.com/t/capistrano-restarts-wrong-release/134251/6 "2008-04-11T15:02:41Z")

</div>

Note that the restart task needs to be in the deploy namespace:

namespace :deploy do  
task :restart, :roles =\> :app do  
# …  
end  
end

Otherwise, you’re not overriding deploy:restart, as you probably are  
intending.

- Jamis
