<div class="gmail_quote">On Fri, Jun 12, 2009 at 6:19 AM, Stefan Washietl <span dir="ltr">&lt;<a href="mailto:wash@paperpile.org">wash@paperpile.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
I&#39;m developing a desktop application using Catalyst and the brand new Titanium framework (<a href="http://www.appcelerator.com/" target="_blank">http://www.appcelerator.com/</a>).<br>
<br>
I need to start/stop the standalone server programatically. Starting is easy, but stopping the server (and its forks) again is tricky. I&#39;d like a solution without keeping track of the PID and explicitely kill it from outside. I want to have something like<br>

<br>
<a href="http://localhost:3000/kill" target="_blank">http://localhost:3000/kill</a><br>
<br>
that calls something in the controller to shut down. The obvious thing<br>
<br>
exit(0);<br>
<br>
does not work. Any ideas how to do this?<br>
<br>
Stefan<br>
<br>
</blockquote><div><br>I just set this up with a combination of HTTP::Prefork and FCGI::Engine::Manager.  I&#39;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.<br>
<br>You&#39;ll have to grab Catalyst::Engine::HTTP::Prefork out of svn, or prod andyg enough so he releases (HEY ANDY!)<br><a href="http://dev.catalystframework.org/repos/Catalyst/trunk/Catalyst-Engine-HTTP-Prefork/">http://dev.catalystframework.org/repos/Catalyst/trunk/Catalyst-Engine-HTTP-Prefork/</a><br>
<br><br>Here&#39;s all the yummy bits from my setup: <a href="http://gist.github.com/128642">http://gist.github.com/128642</a><br><br>You can just run script/myapp_admin.pl start|stop<br><br>One thing, I copied the script/myapp_server.pl over to script/myapp_prefork.pl and changed the default CATALYST_ENGINE to HTTP::Prefork.<br>
<br>This is because I couldn&#39;t figure out a clean way to set the ENV in FCGI::Engine::Manager::Server classes, but it&#39;s a temporary hack until I wrap that up.<br><br>Hope this helps,<br><br>-J<br><br></div></div>