[Catalyst] Killing the standalone perl server programatically

J. Shirley jshirley at gmail.com
Fri Jun 12 13:52:50 GMT 2009


On Fri, Jun 12, 2009 at 6:50 AM, J. Shirley <jshirley at gmail.com> wrote:

> On Fri, Jun 12, 2009 at 6:19 AM, Stefan Washietl <wash at paperpile.org>wrot=
e:
>
>> I'm developing a desktop application using Catalyst and the brand new
>> Titanium framework (http://www.appcelerator.com/).
>>
>> I need to start/stop the standalone server programatically. Starting is
>> easy, but stopping the server (and its forks) again is tricky. I'd like a
>> solution without keeping track of the PID and explicitely kill it from
>> outside. I want to have something like
>>
>> http://localhost:3000/kill
>>
>> that calls something in the controller to shut down. The obvious thing
>>
>> exit(0);
>>
>> does not work. Any ideas how to do this?
>>
>> Stefan
>>
>>
> I just set this up with a combination of HTTP::Prefork and
> FCGI::Engine::Manager.  I'm still floundering away a bit at a refactor of
> FCGI::Engine::Manager that is semantically more sound, but it works well
> enough right now.
>
> You'll have to grab Catalyst::Engine::HTTP::Prefork out of svn, or prod
> andyg enough so he releases (HEY ANDY!)
>
> http://dev.catalystframework.org/repos/Catalyst/trunk/Catalyst-Engine-HTT=
P-Prefork/
>
>
> Here's all the yummy bits from my setup: http://gist.github.com/128642
>
> You can just run script/myapp_admin.pl start|stop
>
> One thing, I copied the script/myapp_server.pl over to
> script/myapp_prefork.pl and changed the default CATALYST_ENGINE to
> HTTP::Prefork.
>
> This is because I couldn't figure out a clean way to set the ENV in
> FCGI::Engine::Manager::Server classes, but it's a temporary hack until I
> wrap that up.
>
> Hope this helps,
>
>
I forgot to finish this off, you can have the kill action then run the stop
command and then everything is going from the same point.  Just executing a
system call to kill it means that the current request should finish cleanly,
along with everything else.

It may be overkill, but that's how I'd do it (just so any post-shutdown
scripts are always executed, etc)

-J
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20090612/ee0b5=
d7e/attachment.htm


More information about the Catalyst mailing list