Forum: Ruby on Rails Switchtower isn't restarting lighttpd

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.
42172acdf3c6046f84d644cb0b94642c?d=identicon&s=25 Pat Maddox (pergesu)
on 2006-01-19 03:07
(Received via mailing list)
I've got switchtower set up, and it seems to work fine except for one
problem: It doesn't successfully restart lighttpd.  I have the
following task in my deploy.rb file:

desc "Restart the web server"
task :restart, :roles => :app do
  sudo "/usr/local/etc/rc.d/lighttpd.sh restart"
end

This is on a FreeBSD system, so it's using the rc script to restart
lighty.  When I run rake deploy, I get the following messages:
[out :: hostname] Stopping lighttpd.
[out :: hostname] Waiting for PIDS: 778
[out :: hostname] .
[out :: hostname] Starting lighttpd.

However, when I try to connect to the server, it won't connect, and a
ps confirms that lighty isn't running.  So I log into the server as
root, manually start it up, and it starts fine.  I check the lighty
logs and there's no error..so I think maybe switchtower disconnects
before the lighty startup process if finished?  I'd really appreciate
some help..once I get switchtower to successfully restart lighty then
everything will be running smoothly.

Thanks,
Pat
992fe8c19bbbc27f2b562a9f96efc03d?d=identicon&s=25 Jamis Buck (Guest)
on 2006-01-19 04:28
(Received via mailing list)
Pat,

I've never been able to get lighty to restart after shutting it down
via SwitchTower. I'm not sure why, either, though others have
suggested it is due to the fact that lighty is being restarted too
soon after being shutdown and perhaps the socket is not available.
(Putting a 10s sleep between the two still doesn't seem to help,
though, so I don't think that's the issue.) Anything you discover
regarding this issue will be appreciated. (Once lighty supports on-
the-fly reloading of config files this all becomes moot, but in the
meantime it's a real show-stopper to use ST with lighty.)

- Jamis
42172acdf3c6046f84d644cb0b94642c?d=identicon&s=25 Pat Maddox (pergesu)
on 2006-01-19 05:40
(Received via mailing list)
Hey Jamis,

I really don't see why there would be a difference in switchtower
anyway, since I'm simply using a built-in RC script to restart lighty.
 Switchtower isn't manually turning lighty off and back on, just
running the script which takes care of everything.  It's giving me the
proper output, so I really don't understand why it's doing this.  Like
I said, my only guess is that perhaps switchtower disconnects before
the startup process finishes..but I just tried sleeping for 10 seconds
after the restart, and that didn't change anything.

Weird.  Anyway, I had read about using reaper to restart the fcgi
processes, maybe I could use that instead?  I also remember a list
message a while back titled "switchtower + reaper = suck" or something
like that.  If you've got any good resources on using lighty with st
I'd appreciate it, in the mean time I'll be googling.

Thanks for the response.

Pat
363548d0cfaaa4bab88747f31ad49c02?d=identicon&s=25 Shane Vitarana (Guest)
on 2006-01-19 07:41
(Received via mailing list)
I am having this exact same problem.  I tried creating a task after
the restart to just call the startup script, but that didn't work
either.

desc "Trying starting again"
task :after_restart, :roles => :app do
  sudo "/usr/local/etc/rc.d/lighttpd.sh start"
end

I have to login to the machine and run the script manually.  I
consider it punishment for cheating with Switchtower in ther first
place :)

Shane
82476266af9d460415d8f1fc16bb54ed?d=identicon&s=25 Jarkko Laine (jarkko)
on 2006-01-19 10:30
(Received via mailing list)
I noticed the same thing, also with a shell script.

//jarkko
8c43ed7f065406bf171c0f3eb32cf615?d=identicon&s=25 Zed Shaw (Guest)
on 2006-01-19 13:07
(Received via mailing list)
If this is the case, you might try using the nohup command.  It
basically runs your command so that it doesn't get destroyed when you
exit.  For example, I have restarted processes using:

nohup /etc/rc.d/thingy restart &

It will write the results to a file nohup.out unless you change this
with command line options.  If lighttpd still dies after you do this
then it's not related to early logout.

Zed
82476266af9d460415d8f1fc16bb54ed?d=identicon&s=25 Jarkko Laine (jarkko)
on 2006-01-19 14:04
(Received via mailing list)
On 19.1.2006, at 13.27, Zed Shaw wrote:

> If this is the case, you might try using the nohup command.  It
> basically runs your command so that it doesn't get destroyed when
> you exit.  For example, I have restarted processes using:
>
> nohup /etc/rc.d/thingy restart &
>
> It will write the results to a file nohup.out unless you change
> this with command line options.  If lighttpd still dies after you
> do this then it's not related to early logout.

Zed,

I tried to change the restart task to use nohup as you describe.
However, this time the whole lighty script is not executed. lighttpd
is still running with the same pid and nohup.out is empty. Everything
looks normal from the switchtower output:

transaction: commit
executing task restart
executing "nohup /users/home/me/bin/lighttpdctrl.sh restart & > /
users/home/me/nohup.out"
servers: ["mydomain.net"]
processing command
[mydomain.net] executing command
command finished

Here's the restart task:
desc "Restart the web server"
task :restart, :roles => :app do
   run "nohup /users/home/me/bin/lighttpdctrl.sh restart & > /users/
home/me/nohup.out"
end

Again, if I run exactly the same command from the shell, restart
works and nohup.out contains the output.

//jarkko

>>  Switchtower isn't manually turning lighty off and back on, just
>> processes, maybe I could use that instead?  I also remember a list
>>> Pat,
>>>
>>>> task :restart, :roles => :app do
>>>> However, when I try to connect to the server, it won't connect,
>>>> Thanks,
>>>
>> _______________________________________________
>> Rails mailing list
>> Rails@lists.rubyonrails.org
>> http://lists.rubyonrails.org/mailman/listinfo/rails
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>

--
Jarkko Laine
http://jlaine.net
http://odesign.fi
42172acdf3c6046f84d644cb0b94642c?d=identicon&s=25 Pat Maddox (pergesu)
on 2006-01-19 14:10
(Received via mailing list)
On 1/19/06, Jarkko Laine <jarkko@jlaine.net> wrote:
> > this with command line options.  If lighttpd still dies after you
> executing task restart
>    run "nohup /users/home/me/bin/lighttpdctrl.sh restart & > /users/
> >
> >> proper output, so I really don't understand why it's doing this.
> >> like that.  If you've got any good resources on using lighty with st
> >>> via SwitchTower. I'm not sure why, either, though others have
> >>> On Jan 18, 2006, at 6:28 PM, Pat Maddox wrote:
> >>>>
> >>>> root, manually start it up, and it starts fine.  I check the lighty
> >>>> Rails mailing list
> >> Rails@lists.rubyonrails.org
> http://odesign.fi
>
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>

Does reaper work at all?  According to
http://duncandavidson.com/essay/2005/12/railsonlighty running rake
deploy should cause reaper to gracefully restart an app's fcgi
processes, without restarting lighttpd.  I'm not seeing anything in
the output though about reaper.

Pat
Ef3aa7f7e577ea8cd620462724ddf73b?d=identicon&s=25 Rob Biedenharn (Guest)
on 2006-01-19 14:47
(Received via mailing list)
Try changing:
run "nohup /users/home/me/bin/lighttpdctrl.sh restart & >
/users/home/me/nohup.out"

into:
run "nohup /users/home/me/bin/lighttpdctrl.sh restart >
/users/home/me/nohup.out 2>&1 &"

The "2>&1" bit captures stderr to the same place as stdout (you want
to see the errors, right?)

The "&" to place the command in the background effectively terminates
the command.  What you have is effectively "nohup lighttpdctrl.sh
restart &" and "> nohup.out" (which is valid and tells the shell to
truncate nohup.out ;-)

-Rob
(Note that this answer is based on my knowledge of Unix systems --
I've not used SwitchTower (yet))
27fa9937f07791744f0e072c7f7889b0?d=identicon&s=25 Alan Francis (Guest)
on 2006-01-19 14:52
> Does reaper work at all?  According to
> http://duncandavidson.com/essay/2005/12/railsonlighty running rake
> deploy should cause reaper to gracefully restart an app's fcgi
> processes, without restarting lighttpd.  I'm not seeing anything in
> the output though about reaper.

Hi Pat,

The default :restart task executes reaper.  Since you have overridden it
with your own restart task to bounce the server instead of the fcgi
processes, reaper wont be run.

If you rename your :restart task to :restart_lighty, ST will fall back
on it's default (reap the fcgi) instead of bouncing the server.  This
should be sufficient for app changes, just not lighty config changes.

If you change the lighty config, you can call the (still broken, can't
help you there :) restart_lighty task manually.  I'm using Apache with
this method , so my restart_apache task works fine when I update, say,
vhost info, but the default :restart just bounces the fcgis.

Alan
42172acdf3c6046f84d644cb0b94642c?d=identicon&s=25 Pat Maddox (pergesu)
on 2006-01-19 15:02
(Received via mailing list)
On 1/19/06, Alan Francis <listsub@twelve71.com> wrote:
> with your own restart task to bounce the server instead of the fcgi
>
> Alan
>
> --
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>

I feel pretty stupid asking this now, but where/what is reaper
exactly?  I don't see anything in my script dir..
992fe8c19bbbc27f2b562a9f96efc03d?d=identicon&s=25 Jamis Buck (Guest)
on 2006-01-19 16:53
(Received via mailing list)
On Jan 19, 2006, at 6:24 AM, Pat Maddox wrote:

> I feel pretty stupid asking this now, but where/what is reaper
> exactly?  I don't see anything in my script dir..

It is located in script/process/reaper. The spawner and spinner are
there also.

- Jamis
38a8230ed3d5c685558b4f0aad3fc74b?d=identicon&s=25 Joe Van Dyk (Guest)
on 2006-01-19 17:33
(Received via mailing list)
On 1/18/06, Shane Vitarana <shanev@gmail.com> wrote:
> consider it punishment for cheating with Switchtower in ther first
> place :)
>
> Shane

Same thing here.  It hought it was just me being dumb.

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