<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Fri, Jan 30, 2015 at 1:25 PM, Michael Van Canneyt <span dir="ltr"><<a href="mailto:michael@freepascal.org" target="_blank">michael@freepascal.org</a>></span> wrote:<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span>
On Fri, 30 Jan 2015, silvioprog wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
      But if you are on a headless server, then a windows service is the only really viable way.<br>
<br>
      You can start messing with run entries in the registry, but the problem remains the same: the app must be running when the<br>
      webserver starts. Best way to achieve that is a service.<br>
<br>
      The alternative is to let the webserver control the program instances.<br>
      And except for debugging purposes, this is still the best approach IMHO.<br>
<br>
But it is very easy to solve it. In my case, when I talk about debug an application running, it isn't about debug the final executable<br>
itself, but its implementation. If I start my EXE via Apache, it is impossible to debug it. Using proxy, I can add another server in<br>
my HTTP server (nginx allows to add more than one), something like "fcgi_pass <IP of my development machine>/dev/myapp", so I open my<br>
browser and access the URL of the server that is running publicly (probably on a machine in the clouds), and this server will call the<br>
application running here on my PC. I know my local application will be a replica of the one already published, taking the time/commits<br>
from the GIT log.<br>
</blockquote>
<br></span>
I know all this. I did this myself :)<br>
<br>
Debugging is currently not the main problem IMHO. Performance is.<br>
<br>
So I am glad you are investigating threaded fastcgi, I will be one of the first to test :)<br>
<br>
Although I am sure this will raise other problems when converting existing fastcgi processes:<br>
such as DB access which is not thread safe, cached data access which must be made thread safe etc. etc. etc.<span><font color="#888888"><br>
<br>
Michael.</font></span><br></blockquote></div><div><br></div><div>Buddy, I finally could make a draft of a FastCGI application running in multi-thread in proxy mode. =)</div><div><br></div><div>It worked on:</div><div><br></div><div>. Windows 7 - 64 bits;</div><div>. nginx 1.7.9 com o módulo FastCGI distribuído nele;</div><div>. Apache 24 (httpd-2.4.12-win64-VC11.zip), que já vem com o módulo FastCGI com suporte ao modo proxy;</div><div>. FPC do trunk.</div><div><br></div><div>And the steps to test it were:<br></div><div><br></div><div>. download and unzip the attached package, after unpacking it, enter the nginx directory and apply its settings in your copy (ainda não testei no Linux, mas farei isso em breve I haven't tested it on Linux yet, but I'll do it soon);</div><div>. open and run the project1.lpr project;</div><div>. open a tab in the browser and access <a href="http://localhost:81/test?op=loop" target="_blank">http://localhost:81/test?op=loop</a>, it is supposed to be frozen for 10 seconds;</div><div>. open another tab in the browser and access <a href="http://localhost:81/test" target="_blank">http://localhost:81/test</a>, it is supposed to show the current time, even with the first tab frozen, this shows that the application is working in multi-thread.</div><div><br></div><div>Follow attached a unit called mycustfcgi.pp, that is a copy of the trunk custfcgi.pp. I've not created a patch because I believe that it will enter a new class in this unit, probably called TFCGIThread, and it won't be necessary a programmer treat the AcceptConnection method externally and not create extra classes, like "TFastCGIThread" and "TFastCGIRouter" as in the example.</div><div><br></div><div>I believe that with some tips of you, I can make this implementation by myself and then send a patch.</div><div><br></div><div>It would be great if this feature has already come in FPC 3.0, which is about to be released. =)</div><div><br></div><div>Thank you!</div><div><br></div>-- <br><div>Silvio Clécio<br>My public projects - <a href="http://github.com/silvioprog" target="_blank">github.com/silvioprog</a></div>
</div></div>