<br>Sam, <br><br>&nbsp;&nbsp;&nbsp; Since this is not going to be generating high traffic (not needing to fork off alot), <br>you might just try Win32::Process::Create().&nbsp; We have a product that does this <br>for each running build on windows and then round robins across non-blocking sockets
<br>within each process in order to avoid forking a bunch of times.&nbsp;&nbsp; Note that this is tricky<br>and you have to watch out for deadlocks or a single socket over-consuming all the processing time.<br>&nbsp;&nbsp;&nbsp; Our product is used for kicking off builds and maintaining information about it in a web UI.
<br>It&#39;s very flexible, and written in Perl / PHP / C with Eclipse and Visual studio plugins, the downside is it&#39;s a bit expensive if this is just a side thing.<br>&nbsp;&nbsp;&nbsp; Here&#39;s a link to one of our open-source competitors (not nearly the feature set and written in java it would appear, but it looks interesting): 
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="http://luntbuild.javaforge.com/">http://luntbuild.javaforge.com/</a><br><br><br>&nbsp; --Heath<br><br><div><span class="gmail_quote">On 2/9/07, <b class="gmail_sendername"><a href="mailto:austin-request@pm.org">
austin-request@pm.org</a></b> &lt;<a href="mailto:austin-request@pm.org">austin-request@pm.org</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Send Austin mailing list submissions to<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="mailto:austin@pm.org">austin@pm.org</a><br><br>To subscribe or unsubscribe via the World Wide Web, visit<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="http://mail.pm.org/mailman/listinfo/austin">
http://mail.pm.org/mailman/listinfo/austin</a><br>or, via email, send a message with subject or body &#39;help&#39; to<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="mailto:austin-request@pm.org">austin-request@pm.org</a><br><br>You can reach the person managing the list at
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="mailto:austin-owner@pm.org">austin-owner@pm.org</a><br><br>When replying, please edit your Subject line so it is more specific<br>than &quot;Re: Contents of Austin digest...&quot;<br><br><br>Today&#39;s Topics:
<br><br>&nbsp;&nbsp; 1. fork on windows / long-running process and cgi (Sam Foster)<br>&nbsp;&nbsp; 2. Re: fork on windows / long-running process and cgi<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(Montgomery Conner)<br>&nbsp;&nbsp; 3. Re: fork on windows / long-running process and cgi (Sam Foster)
<br>&nbsp;&nbsp; 4. Re: fork on windows / long-running process and cgi<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(Taylor Carpenter)<br>&nbsp;&nbsp; 5. Re: fork on windows / long-running process and cgi (Tim McDaniel)<br>&nbsp;&nbsp; 6. Re: fork on windows / long-running process and cgi (Sam Foster)
<br><br><br>----------------------------------------------------------------------<br><br>Message: 1<br>Date: Thu, 08 Feb 2007 15:37:11 -0600<br>From: Sam Foster &lt;<a href="mailto:austin.pm@sam-i-am.com">austin.pm@sam-i-am.com
</a>&gt;<br>Subject: APM: fork on windows / long-running process and cgi<br>To: &quot;<a href="http://austin.pm">austin.pm</a>&quot; &lt;<a href="mailto:austin@pm.org">austin@pm.org</a>&gt;<br>Message-ID: &lt;<a href="mailto:45CB9807.6030509@sam-i-am.com">
45CB9807.6030509@sam-i-am.com</a>&gt;<br>Content-Type: text/plain; charset=ISO-8859-1; format=flowed<br><br>so what is the skinny with fork on windows? No, not ever, yes with some<br>workarounds, yes with a particular distribution of perl for win32s?
<br><br>I&#39;m trying to put a web front-end on a build process - that may take a<br>while. Ideally my initial request would kick off the build, and later<br>requests would check on its status and finally pick up the output and
<br>send it or a link to it back to the client.<br>I&#39;m developing on and will ultimately be deploying to a windows xp box<br>with apache and activestate&#39;s perl.<br><br>So, it would seem that I should fork to kick the process off, send back
<br>a &quot;working...&quot; message as a response and close stdout in the parent<br>process.<br>The child process goes on working, putting output from the build script<br>into a file.<br><br>The client would keep polling every few seconds to check status, and
<br>grab and respond with the build script output, which will finally<br>include a link to where the user can download a zip of the output.<br><br>This is just for internal usage, and wont get high traffic. Concurrent<br>
requests are possible, but honestly quite unlikely. In fact, depending<br>on the load on the server, the build usually finishes inside a minute so<br>I could probably keep it simple and just sit and wait for the response -
<br>but I&#39;d like to know what my options are. I do need input (config data)<br>from the user so I cant just schedule this and run it nightly or something.<br><br>Oh, and this is supposed to be a fun diversion from my real job, so if
<br>I&#39;m trying to make it too complicated that&#39;s why :)<br>thanks for any thoughts<br>Sam<br><br><br><br>------------------------------<br><br>Message: 2<br>Date: Thu, 8 Feb 2007 18:45:02 -0600<br>From: &quot;Montgomery Conner&quot; &lt;
<a href="mailto:montgomery.conner@gmail.com">montgomery.conner@gmail.com</a>&gt;<br>Subject: Re: APM: fork on windows / long-running process and cgi<br>To: &quot;Sam Foster&quot; &lt;<a href="mailto:austin.pm@sam-i-am.com">
austin.pm@sam-i-am.com</a>&gt;<br>Cc: &quot;<a href="http://austin.pm">austin.pm</a>&quot; &lt;<a href="mailto:austin@pm.org">austin@pm.org</a>&gt;<br>Message-ID:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;<a href="mailto:e8c2cfe90702081645n299689ceg7113100323c41dac@mail.gmail.com">
e8c2cfe90702081645n299689ceg7113100323c41dac@mail.gmail.com</a>&gt;<br>Content-Type: text/plain; charset=&quot;iso-8859-1&quot;<br><br>As I understand Perl&#39;s fork() corresponds to the OS system call for *nix<br>distros... since there is no equivalent system call on Windows, fork() will
<br>not work.&nbsp;&nbsp;The ActiveState<br>&lt;<a href="http://www.xav.com/perl/lib/Pod/perlfork.html">http://www.xav.com/perl/lib/Pod/perlfork.html</a>&gt;site includes some<br>information on fork() emulation for Windows:<br><br>
The fork() &lt;<a href="http://www.xav.com/perl/lib/Pod/perlfunc.html#item_fork">http://www.xav.com/perl/lib/Pod/perlfunc.html#item_fork</a>&gt;emulation<br>is implemented at the level of the Perl interpreter. What this<br>
means in general is that running<br>fork()&lt;<a href="http://www.xav.com/perl/lib/Pod/perlfunc.html#item_fork">http://www.xav.com/perl/lib/Pod/perlfunc.html#item_fork</a>&gt;will<br>actually clone the running interpreter and all its state, and run the
<br>cloned interpreter in a separate thread, beginning execution in the new<br>thread just after the point where the<br>fork()&lt;<a href="http://www.xav.com/perl/lib/Pod/perlfunc.html#item_fork">http://www.xav.com/perl/lib/Pod/perlfunc.html#item_fork
</a>&gt;was<br>called in the parent.<br><br>I would assume that using this mechanism will incur the memory hit that<br>comes with duplicating the entire Perl interpreter for each call to fork().<br>You would have to test this to be certain...
<br><br><br>Have you worked with the POE multitasking framework before?&nbsp;&nbsp;I&#39;ve found that<br>it is a useful (and fun!) alternative when I need a multitasking application<br>on Windows (or ever!).&nbsp;&nbsp;By writing a simple web-server in
<br>POE&lt;<a href="http://search.cpan.org/search?query=poe&amp;mode=all">http://search.cpan.org/search?query=poe&amp;mode=all</a>&gt;(a truly trivial<br>task) you&#39;d have a multitasking non-blocking application<br>that could listen and delegate appropriately.&nbsp;&nbsp;Check-out the cookbook at the
<br>project homepage for some ideas: <a href="http://poe.perl.org/">http://poe.perl.org/</a><br><br><br>Good Luck!<br>Montgomery<br><br><br>On 2/8/07, Sam Foster &lt;<a href="mailto:austin.pm@sam-i-am.com">austin.pm@sam-i-am.com
</a>&gt; wrote:<br>&gt;<br>&gt; so what is the skinny with fork on windows? No, not ever, yes with some<br>&gt; workarounds, yes with a particular distribution of perl for win32s?<br>&gt;<br>&gt; I&#39;m trying to put a web front-end on a build process - that may take a
<br>&gt; while. Ideally my initial request would kick off the build, and later<br>&gt; requests would check on its status and finally pick up the output and<br>&gt; send it or a link to it back to the client.<br>&gt; I&#39;m developing on and will ultimately be deploying to a windows xp box
<br>&gt; with apache and activestate&#39;s perl.<br>&gt;<br>&gt; So, it would seem that I should fork to kick the process off, send back<br>&gt; a &quot;working...&quot; message as a response and close stdout in the parent
<br>&gt; process.<br>&gt; The child process goes on working, putting output from the build script<br>&gt; into a file.<br>&gt;<br>&gt; The client would keep polling every few seconds to check status, and<br>&gt; grab and respond with the build script output, which will finally
<br>&gt; include a link to where the user can download a zip of the output.<br>&gt;<br>&gt; This is just for internal usage, and wont get high traffic. Concurrent<br>&gt; requests are possible, but honestly quite unlikely. In fact, depending
<br>&gt; on the load on the server, the build usually finishes inside a minute so<br>&gt; I could probably keep it simple and just sit and wait for the response -<br>&gt; but I&#39;d like to know what my options are. I do need input (config data)
<br>&gt; from the user so I cant just schedule this and run it nightly or<br>&gt; something.<br>&gt;<br>&gt; Oh, and this is supposed to be a fun diversion from my real job, so if<br>&gt; I&#39;m trying to make it too complicated that&#39;s why :)
<br>&gt; thanks for any thoughts<br>&gt; Sam<br>&gt;<br>&gt; _______________________________________________<br>&gt; Austin mailing list<br>&gt; <a href="mailto:Austin@pm.org">Austin@pm.org</a><br>&gt; <a href="http://mail.pm.org/mailman/listinfo/austin">
http://mail.pm.org/mailman/listinfo/austin</a><br>&gt;<br>-------------- next part --------------<br>An HTML attachment was scrubbed...<br>URL: <a href="http://mail.pm.org/pipermail/austin/attachments/20070208/46f84c4e/attachment.htm">
http://mail.pm.org/pipermail/austin/attachments/20070208/46f84c4e/attachment.htm</a><br><br>------------------------------<br><br>Message: 3<br>Date: Thu, 08 Feb 2007 20:24:33 -0600<br>From: Sam Foster &lt;<a href="mailto:austin.pm@sam-i-am.com">
austin.pm@sam-i-am.com</a>&gt;<br>Subject: Re: APM: fork on windows / long-running process and cgi<br>To: &quot;<a href="http://austin.pm">austin.pm</a>&quot; &lt;<a href="mailto:austin@pm.org">austin@pm.org</a>&gt;<br>Message-ID: &lt;
<a href="mailto:45CBDB61.2060201@sam-i-am.com">45CBDB61.2060201@sam-i-am.com</a>&gt;<br>Content-Type: text/plain; charset=ISO-8859-1; format=flowed<br><br><br>&gt;<br>&gt; Have you worked with the POE multitasking framework before?&nbsp;&nbsp;I&#39;ve
<br>&gt; found that it is a useful (and fun!) alternative when I need a<br>&gt; multitasking application on Windows (or ever!).&nbsp;&nbsp;By writing a simple<br>&gt; web-server in POE &lt;<a href="http://search.cpan.org/search?query=poe&amp;mode=all">
http://search.cpan.org/search?query=poe&amp;mode=all</a>&gt;<br>&gt; (a truly trivial task) you&#39;d have a multitasking non-blocking<br>&gt; application that could listen and delegate appropriately.&nbsp;&nbsp;Check-out<br>&gt; the cookbook at the project homepage for some ideas: 
<a href="http://poe.perl.org/">http://poe.perl.org/</a><br>&gt;<br>See, that&#39;s what I&#39;m talking about with needlessly over-complicating<br>things :) Ok, I&#39;ll bite, been wanting to look at POE for a while now anyhow
<br><br>Sam<br><br><br><br>------------------------------<br><br>Message: 4<br>Date: Thu, 8 Feb 2007 23:43:56 -0600<br>From: Taylor Carpenter &lt;<a href="mailto:taylor@codecafe.com">taylor@codecafe.com</a>&gt;<br>Subject: Re: APM: fork on windows / long-running process and cgi
<br>To: &quot;<a href="http://austin.pm">austin.pm</a>&quot; &lt;<a href="mailto:austin@pm.org">austin@pm.org</a>&gt;<br>Message-ID: &lt;<a href="mailto:1060765E-723C-443B-B20F-732EBE02498F@codecafe.com">1060765E-723C-443B-B20F-732EBE02498F@codecafe.com
</a>&gt;<br>Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed<br><br>An alternative to POE and your normal thoughts on using fork() is to<br>sharing the information about the current build state &quot;outside of the
<br>CGI app&quot;.&nbsp;&nbsp;You can have some CGI app start the build based on certain<br>input (startbuild=1 or whatever) then another script (ot it called<br>differently) can check on the build state (checkbuild=1).&nbsp;&nbsp;When the<br>
build is finished instead of showing current status it redirects to a<br>page that shows full status of the build and the link etc.<br><br>You have many options including<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;simple text file that you read from
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DB (sqlite would be easy)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;memcache (<a href="http://search.cpan.org/~bradfitz/Cache-Memcached-1.18/">http://search.cpan.org/~bradfitz/Cache-Memcached-1.18/</a> -<br><a href="http://www.danga.com/memcached">
http://www.danga.com/memcached</a>)<br><br>Randal L. Schwartz has an article on watching long running processes<br>through CGI using Cache::Cache and Apache::Session<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="http://www.stonehenge.com/merlyn/LinuxMag/col39.html">
http://www.stonehenge.com/merlyn/LinuxMag/col39.html</a><br><br>You mentioned having config data from the user.&nbsp;&nbsp;You could also<br>create a file in a directory and check that &quot;incoming&quot; directory for<br>the config information.&nbsp;&nbsp;It would remove the file and start the
<br>build.&nbsp;&nbsp;That could be an app that is always running or something<br>setup in Windows scheduler.&nbsp;&nbsp;Another CGI would show the status of any<br>running builds or finished builds.&nbsp;&nbsp;That information can be stored<br>and various ways including those I mentioned previously.
<br><br>On Feb 8, 2007, at 3:37 PM, Sam Foster wrote:<br><br>&gt; so what is the skinny with fork on windows? No, not ever, yes with<br>&gt; some<br>&gt; workarounds, yes with a particular distribution of perl for win32s?
<br>&gt;<br>&gt; I&#39;m trying to put a web front-end on a build process - that may take a<br>&gt; while. Ideally my initial request would kick off the build, and later<br>&gt; requests would check on its status and finally pick up the output and
<br>&gt; send it or a link to it back to the client.<br><br><br>------------------------------<br><br>Message: 5<br>Date: Thu, 8 Feb 2007 23:56:57 -0600 (CST)<br>From: Tim McDaniel &lt;<a href="mailto:tmcd@panix.com">tmcd@panix.com
</a>&gt;<br>Subject: Re: APM: fork on windows / long-running process and cgi<br>Cc: &quot;<a href="http://austin.pm">austin.pm</a>&quot; &lt;<a href="mailto:austin@pm.org">austin@pm.org</a>&gt;<br>Message-ID: &lt;<a href="mailto:Pine.NEB.4.64.0702082353580.1305@panix3.panix.com">
Pine.NEB.4.64.0702082353580.1305@panix3.panix.com</a>&gt;<br>Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed<br><br>On Feb 8, 2007, at 3:37 PM, Sam Foster wrote:<br>&gt; I&#39;m trying to put a web front-end on a build process - that may take
<br>&gt; a while. Ideally my initial request would kick off the build, and<br>&gt; later requests would check on its status and finally pick up the<br>&gt; output and send it or a link to it back to the client.<br><br>&quot;Micro-optimizations yield micro-results.&quot;&nbsp;&nbsp;You will do builds what,
<br>several times a day, and check their statuses a few dozen times a day?<br>Unless fork() simply didn&#39;t work (and it does work, in my experience<br>with Cygwin&#39;s perl at least), I don&#39;t see why you&#39;d bother to avoid
<br>it.&nbsp;&nbsp;Am I missing something?<br><br>Daniel de Lyncoln<br>--<br>Tim McDaniel, <a href="mailto:tmcd@panix.com">tmcd@panix.com</a><br><br><br>------------------------------<br><br>Message: 6<br>Date: Fri, 09 Feb 2007 13:21:21 -0600
<br>From: Sam Foster &lt;<a href="mailto:austin.pm@sam-i-am.com">austin.pm@sam-i-am.com</a>&gt;<br>Subject: Re: APM: fork on windows / long-running process and cgi<br>To: &quot;<a href="http://austin.pm">austin.pm</a>&quot; &lt;
<a href="mailto:austin@pm.org">austin@pm.org</a>&gt;<br>Message-ID: &lt;<a href="mailto:45CCC9B1.4030506@sam-i-am.com">45CCC9B1.4030506@sam-i-am.com</a>&gt;<br>Content-Type: text/plain; charset=ISO-8859-1; format=flowed<br>
<br><br>&gt; &quot;Micro-optimizations yield micro-results.&quot;&nbsp;&nbsp;You will do builds what,<br>&gt; several times a day, and check their statuses a few dozen times a day?<br>&gt; Unless fork() simply didn&#39;t work (and it does work, in my experience
<br>&gt; with Cygwin&#39;s perl at least), I don&#39;t see why you&#39;d bother to avoid<br>&gt; it.&nbsp;&nbsp;Am I missing something?<br>&gt;<br>&gt;<br>I had made a first pass at this and ran into problems which seemed to<br>center right around where my script was supposed to be forking. Rather
<br>than bang my head against it I thought I&#39;d check if this is even<br>supposed to work, or what other options there are. Taylor is right<br>though that I really dont need a fork, I just need to kick off the<br>process, hang up with a response (I just close stdout right?) and let a
<br>future request check on the status. I&#39;m already persisting some info<br>about the build to a file so I could add build status in there.<br><br>Tim: all you are missing is that in truth I dont know what I&#39;m doing, so
<br>my uncertainty is not about optimization, more about learning good<br>patterns that will serve me in the future.<br><br>Sam<br><br><br>------------------------------<br><br>_______________________________________________
<br>Austin mailing list<br><a href="mailto:Austin@pm.org">Austin@pm.org</a><br><a href="http://mail.pm.org/mailman/listinfo/austin">http://mail.pm.org/mailman/listinfo/austin</a><br><br>End of Austin Digest, Vol 44, Issue 3
<br>*************************************<br></blockquote></div><br>