Forum: Ruby on Rails Capistrano: command never finishes?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
B9a732fc30c32098347a0177c75ee27b?d=identicon&s=25 Jeroen Houben (Guest)
on 2006-03-07 13:20
(Received via mailing list)
Hi,

I have created a small :restart task to overwrite the default one:

task :restart, :roles => :app do
   sudo "/etc/init.d/lighttpd stop"
   sudo "/etc/init.d/lighttpd start"
end

This works fine and lighty does restart, but the last command never
finishes, so I never return to the prompt. Here's my output:

  cap restart
     loading configuration
/usr/lib/ruby/gems/1.8/gems/capistrano-1.1.0/lib/capistrano/recipes/standard.rb
     loading configuration ./config/deploy.rb
   * executing task restart
   * executing "sudo /etc/init.d/lighttpd stop"
     servers: ["ror1.tienhuis.nl"]
     [ror1.tienhuis.nl] executing command
  ** [out :: ror1.tienhuis.nl] Stopping web server: lighttpd
  ** [out :: ror1.tienhuis.nl] .
     command finished
   * executing "sudo /etc/init.d/lighttpd start"
     servers: ["ror1.tienhuis.nl"]
     [ror1.tienhuis.nl] executing command
  ** [out :: ror1.tienhuis.nl] Starting web server: lighttpd
  ** [out :: ror1.tienhuis.nl] .

---- nothing happens for a long time so I press ctr-c .... ------

/usr/lib/ruby/gems/1.8/gems/capistrano-1.1.0/lib/capistrano/command.rb:39:in
`sleep': Interrupt
         from
/usr/lib/ruby/gems/1.8/gems/capistrano-1.1.0/lib/capistrano/command.rb:39:in
`process!'
         from
/usr/lib/ruby/gems/1.8/gems/capistrano-1.1.0/lib/capistrano/command.rb:26:in
`loop'
         from
/usr/lib/ruby/gems/1.8/gems/capistrano-1.1.0/lib/capistrano/command.rb:26:in
`process!'
         from
/usr/lib/ruby/gems/1.8/gems/capistrano-1.1.0/lib/capistrano/actor.rb:176:in
`run'
         from
/usr/lib/ruby/gems/1.8/gems/capistrano-1.1.0/lib/capistrano/actor.rb:173:in
`execute_on_servers'
         from
/usr/lib/ruby/gems/1.8/gems/capistrano-1.1.0/lib/capistrano/actor.rb:173:in
`run'
         from
/usr/lib/ruby/gems/1.8/gems/capistrano-1.1.0/lib/capistrano/actor.rb:221:in
`sudo'
         from ./config/deploy.rb:64:in `instance_eval'
          ... 9 levels...
         from
/usr/lib/ruby/gems/1.8/gems/capistrano-1.1.0/lib/capistrano/cli.rb:12:in
`execute!'
         from /usr/lib/ruby/gems/1.8/gems/capistrano-1.1.0/bin/cap:11
         from /usr/bin/cap:18:in `load'
         from /usr/bin/cap:18

Any ideas? Doing this on the command line on my remote server works
instantly.

Jeroen


BTW: I've successfully migrated to capistrano by following the steps
mentioned on the RoR blog entry. Easy! I can see this tool becoming
quite handy over time.
992fe8c19bbbc27f2b562a9f96efc03d?d=identicon&s=25 Jamis Buck (Guest)
on 2006-03-07 15:19
(Received via mailing list)
Jeroen,

For some reason I have never been able to determine, lighttpd does
not like to be restarted via capistrano. :( Sometimes it hangs (as
you're observing) and other times it appears to finish successfully,
but lighttpd never gets restarted.

I've never observed this behavior with any other application--just
lighttpd. Many other people have observed this as well. I wish I knew
of a workaround you could try, but this has really stumped me for a
long time.

You might want to look into using external fastcgi processes, instead
of lighttpd-spawned ones, so that you can restart the fcgi's without
having to restart lighttpd. Other than that, I'm not sure what to you
tell you. :(

Good luck,

Jamis
7c4087d053eb02d099a17d91ba5e33b5?d=identicon&s=25 Brian V. Hughes (Guest)
on 2006-03-07 15:34
(Received via mailing list)
I'm still on ST, but all of my Rails apps are served by lighttpd spawned
fastcgi
processes. And on every one of them ./script/process/reaper is all I
ever need
to do, to reload my apps code. In fact, the only ST change I needed to
make was
setting it to just "run" not "sudo". The rest just flat worked.

-Brian
B9a732fc30c32098347a0177c75ee27b?d=identicon&s=25 Jeroen Houben (Guest)
on 2006-03-07 16:36
(Received via mailing list)
Jamis Buck wrote:
>
> You might want to look into using external fastcgi processes, instead of
> lighttpd-spawned ones, so that you can restart the fcgi's without having
> to restart lighttpd. Other than that, I'm not sure what to you tell you. :(
>

Thanks Jamis! Is there a quick way to see what exactly cap is doing? If
it means anything, I'm running ruby 1.8.4 rails 1.0 and lighty 1.4.8

I indeed would like to use externally spawned processes (reaper/spinner)
but I need to think about how to do this because my setup is a bit
awkward and I initially wasn't going to bore you with that...  Please
feel free to ignore this question as it's kind of OT ;-)

I'm trying to run several apps using one installation. I have the app
installed in /w/tennis

Then I have individual club sites

/sites/club1
/sites/club2
/sites/club3

All these are plain symlinks to /w/tennis - except the CSS and some
images directories which should remain unique per site.

lighty.conf has this for each site (= vhost):
"bin-path" => "/sites/"+var.appname+"/public/dispatch.fcgi",

But capistrano wants to restart a different process:

   * executing "sudo /w/tennis/current/script/process/reaper"
     servers: ["ror1.tienhuis.nl"]
     [ror1.tienhuis.nl] executing command
  ** [out :: ror1.tienhuis.nl] Couldn't find any process matching:
/w/tennis/current/public/dispatch.fcgi
     command finished

I could use this in lighty.conf and reference the only real
dispatch.fcgi:

"bin-path" => "/w/tennis/public/dispatch.fcgi"

But then the environment gets screwed because Rails loads the wrong
paths.


So basically I'm a bit lost as two how to deploy multiple sites using
one "base installation". If anybody has any good pointers, please let me
know!

Jeroen
992fe8c19bbbc27f2b562a9f96efc03d?d=identicon&s=25 Jamis Buck (Guest)
on 2006-03-07 21:48
(Received via mailing list)
On Mar 7, 2006, at 8:34 AM, Jeroen Houben wrote:

>> You might want to look into using external fastcgi processes,
> is a bit awkward and I initially wasn't going to bore you with
> /sites/club3
>     servers: ["ror1.tienhuis.nl"]
> But then the environment gets screwed because Rails loads the wrong
> paths.
>
>
> So basically I'm a bit lost as two how to deploy multiple sites
> using one "base installation". If anybody has any good pointers,
> please let me know!

The problem here is that the reaper doesn't know what the name of
your dispatcher is. It tries to grep the process list to find a
matching one, and the default selection criteria are failing.

If you know some unique string for finding the dispatcher processes
in the list of running processes, you can write your own restart task:

   task :restart, :only => :app do
     sudo "kill `ps wwax | grep 'some unique stuff' | grep -v grep |
cut -b 1-5`"
   end

That's more or less what the reaper does.

- Jamis
B9a732fc30c32098347a0177c75ee27b?d=identicon&s=25 Jeroen Houben (Guest)
on 2006-03-08 10:55
(Received via mailing list)
Jamis Buck wrote:

>
>   task :restart, :only => :app do
>     sudo "kill `ps wwax | grep 'some unique stuff' | grep -v grep | cut
> -b 1-5`"
>   end
>
> That's more or less what the reaper does.

Thanks Jamis.

I first used your clever "kill-grep" command which worked, but then I
looked closely at the reaper script and indeed saw it already has built
in support for finding other processes than the standard
public/dispatch.fcgi in the app directory. I now use this:

task :restart, :roles => :app do
   send(run_method, "#{current_path}/script/process/reaper -d mystring")
end

Where "mystring" identifies part of the path to dispatch.fcgi
This works great, it finds all relevant processes and restarts them.

Thanks a lot!

Jeroen
This topic is locked and can not be replied to.