# How to pause between mongrel stop and start in "cap deploy"

**URL:** <https://www.ruby-forum.com/t/how-to-pause-between-mongrel-stop-and-start-in-cap-deploy/117253>\
**Category:** Deployment\
**Created:** [October 15, 2007, 12:44pm UTC](https://www.ruby-forum.com/t/how-to-pause-between-mongrel-stop-and-start-in-cap-deploy/117253 "2007-10-15T12:44:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dxk3355](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/d6d6ee/32.png) [@dxk3355](https://www.ruby-forum.com/u/dxk3355)\
**Post date:** [October 15, 2007, 12:44pm UTC](https://www.ruby-forum.com/t/how-to-pause-between-mongrel-stop-and-start-in-cap-deploy/117253/1 "2007-10-15T12:44:36Z")

</div>

Hi!

Sometimes when doing “cap deploy”, the process finishes by:

\*\* [out :: unebo] stopping port 6500  
\*\* [out :: unebo] already started port 6500  
command finished

It seems that mongrel didn’t have the time to stop before capistrano  
tried to start it again. I suspect this is the cause, because something  
like 50% it is working no problem.

When it happens though, I just issue “cap deploy:start” and everything  
is ok.

I wonder if it is possible to include some little delay (1 or 2 seconds)  
between stopping and starting mongrels…

thank you very much!

david

---

<div class="post-metadata">

**Author:** ![dxk3355](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/d6d6ee/32.png) [@dxk3355](https://www.ruby-forum.com/u/dxk3355)\
**Post date:** [October 15, 2007, 12:45pm UTC](https://www.ruby-forum.com/t/how-to-pause-between-mongrel-stop-and-start-in-cap-deploy/117253/2 "2007-10-15T12:45:11Z")

</div>

forgot to mention: I use this in my deploy.rb file:

set :mongrel\_conf,  
“/var/www/#{application}/current/config/mongrel\_cluster.yml”

namespace :deploy do  
namespace :mongrel do  
[:stop, :start, :restart].each do |t|  
desc “#{t.to\_s.capitalize} the mongrel appserver”  
task t, :roles =\> :app do  
#invoke\_command checks the use\_sudo variable to determine how to  
run th$  
invoke\_command “mongrel\_rails cluster::#{t.to\_s} -C  
#{mongrel\_conf}”, 😊  
end  
end  
end

desc “Custom restart task for mongrel cluster”  
task :restart, :roles =\> :app, :except =\> { :no\_release =\> true } do  
deploy.mongrel.restart  
end

desc “Custom stop task for mongrel cluster”  
task :stop, :roles =\> :app do  
deploy.mongrel.stop  
end

end

---

<div class="post-metadata">

**Author:** ![dxk3355](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/d6d6ee/32.png) [@dxk3355](https://www.ruby-forum.com/u/dxk3355)\
**Post date:** [January 22, 2008, 8:38pm UTC](https://www.ruby-forum.com/t/how-to-pause-between-mongrel-stop-and-start-in-cap-deploy/117253/3 "2008-01-22T20:38:58Z")

</div>

D. Krmpotic wrote:

> I wonder if it is possible to include some little delay (1 or 2 seconds)  
> between stopping and starting mongrels…

We rewrote the deploy:restart task, making it manually stop and start  
mongrel, along with a 2.5 sec ‘nap’ in between. For us, mongrel\_rails  
cluster::restart doesn’t work reliably, especially with many mongrels  
running.

namespace(:deploy) do

(…)

desc “Restart the Mongrel processes on the app server by calling  
restart\_mongrel\_cluster.”  
task :restart, :roles =\> :app do  
#mongrel.cluster.restart  
mongrel.cluster.stop  
sleep 2.5  
mongrel.cluster.start  
apache.restart  
end

(…)  
end
