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.
Pat M. (Guest)
on 2006-01-19 04: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
Jamis B. (Guest)
on 2006-01-19 05: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
Pat M. (Guest)
on 2006-01-19 06: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
Shane V. (Guest)
on 2006-01-19 08: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
Jarkko L. (Guest)
on 2006-01-19 11:30
(Received via mailing list)
I noticed the same thing, also with a shell script.

//jarkko
Zed S. (Guest)
on 2006-01-19 14: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
Jarkko L. (Guest)
on 2006-01-19 15:04
(Received via mailing list)
On 19.1.2006, at 13.27, Zed S. 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
>> removed_email_address@domain.invalid
>> http://lists.rubyonrails.org/mailman/listinfo/rails
> _______________________________________________
> Rails mailing list
> removed_email_address@domain.invalid
> http://lists.rubyonrails.org/mailman/listinfo/rails
>

--
Jarkko L.
http://jlaine.net
http://odesign.fi
Pat M. (Guest)
on 2006-01-19 15:10
(Received via mailing list)
On 1/19/06, Jarkko L. <removed_email_address@domain.invalid> 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 M. wrote:
> >>>>
> >>>> root, manually start it up, and it starts fine.  I check the lighty
> >>>> Rails mailing list
> >> removed_email_address@domain.invalid
> http://odesign.fi
>
> _______________________________________________
> Rails mailing list
> removed_email_address@domain.invalid
> 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
Rob B. (Guest)
on 2006-01-19 15: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))
Alan F. (Guest)
on 2006-01-19 15: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
Pat M. (Guest)
on 2006-01-19 16:02
(Received via mailing list)
On 1/19/06, Alan F. <removed_email_address@domain.invalid> 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
> removed_email_address@domain.invalid
> 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..
Jamis B. (Guest)
on 2006-01-19 17:53
(Received via mailing list)
On Jan 19, 2006, at 6:24 AM, Pat M. 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
Joe Van D. (Guest)
on 2006-01-19 18:33
(Received via mailing list)
On 1/18/06, Shane V. <removed_email_address@domain.invalid> 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.