# Cluster::restart doesn't wait for stop before starting

**URL:** <https://www.ruby-forum.com/t/cluster-restart-doesnt-wait-for-stop-before-starting/118519>\
**Category:** Mongrel\
**Created:** [October 28, 2007, 2:12am UTC](https://www.ruby-forum.com/t/cluster-restart-doesnt-wait-for-stop-before-starting/118519 "2007-10-28T02:12:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![arvliet](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ee59a6/32.png) [@arvliet](https://www.ruby-forum.com/u/arvliet)\
**Post date:** [October 28, 2007, 2:12am UTC](https://www.ruby-forum.com/t/cluster-restart-doesnt-wait-for-stop-before-starting/118519/1 "2007-10-28T02:12:36Z")

</div>

Hi,

I’m calling restart from my Capistrano task. I have this in my deploy.rb  
file:

# until mongrel\_cluster updates to cap2…

namespace :deploy do  
task :start, :roles =\> :app do start\_mongrel\_cluster end  
task :stop, :roles =\> :app do stop\_mongrel\_cluster end  
task :restart, :roles =\> :app do restart\_mongrel\_cluster end  
end

(What’s the scoop on mongrel\_cluster with Capistrano 2 by the way?)

The command that’s executed with a restart is:

sudo mongrel\_rails cluster::restart -C /etc/mongrel\_cluster/staging.yml

\*\* [out :: 208.75.84.228] stopping port 8010  
\*\* [out :: 208.75.84.228] already started port 8010

At this point the server is not running – I conclude that it has been  
stopped successfully. Now if I call on “start” it starts properly  
without an “already started” warning.

This happens intermittently. Sometimes it restarts fine. If I call  
stop/start manually, it works because I guess I’m leaving enough time  
in between for it to shut down.

Any thoughts on this?

capistrano 2.0.0  
mongrel 1.0.1  
mongrel\_rails 1.0.2

–Andrew V.

---

<div class="post-metadata">

**Author:** ![arvliet](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ee59a6/32.png) [@arvliet](https://www.ruby-forum.com/u/arvliet)\
**Post date:** [October 28, 2007, 2:56pm UTC](https://www.ruby-forum.com/t/cluster-restart-doesnt-wait-for-stop-before-starting/118519/2 "2007-10-28T14:56:05Z")

</div>

It would be good if it were redesigned to listen for the mongrel to  
finish  
before starting it again, every time I stop our front end mongrels one  
or  
two of them don’t stop quick enough (there are a lot of 1/2-1 sec pages)  
and  
i’m pressing up/enter/up/enter/up/enter to start them up again as fast  
as  
possible.  
(anyway, what i meant to add was its not a Capistrano issue alone)

---

<div class="post-metadata">

**Author:** ![arvliet](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ee59a6/32.png) [@arvliet](https://www.ruby-forum.com/u/arvliet)\
**Post date:** [October 28, 2007, 2:57pm UTC](https://www.ruby-forum.com/t/cluster-restart-doesnt-wait-for-stop-before-starting/118519/3 "2007-10-28T14:57:50Z")

</div>

We notice this a lot in our environment because some mongrels in the  
cluster are assigned to handle image magick tasks and can take a while  
to acknowledge the TERM signal.

From my understanding mongrel\_rails cluster::restart sends a TERM to  
each mongel, which causes it to wait for the currently processing  
request to finish, then closes the connections of the other requests  
outstanding. If this doesn’t happen straight away then you’ll get the  
already started message.

The solution to me would seam to give cluster::restart an optional  
delay parameter so those slow mongrels can catch up.

Cheers

Dave
