How to use FCGI?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

How to use FCGI?

Stootch
Hello,

Can anybody enlighten me on how to use FCGI from fcl-web package? Is it working code at all?
From what I know FastCGI application should be running seperately from http server and be connectable via sockets, whereas I cannot find any socket-related calls like (fp)Bind or fp(Listen) in the code (FPC 2.3.1). Only fpAccept exists inside of custfcgi.pp which tries to accept connection from StdInputHandle, and this looks somehow cryptic to me. But maybe I am missing something?

Artur
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: How to use FCGI?

Joost van der Sluis
Op woensdag 08-07-2009 om 16:09 uur [tijdzone +0200], schreef Artur
Stuczyński:
> Can anybody enlighten me on how to use FCGI from fcl-web package? Is it working code at all?

Someone here said it didn't work on windows, but I think that's fixed in
the mean time. Linux should work, further I didn't test.

> From what I know FastCGI application should be running seperately from http server and be connectable via sockets, whereas I cannot find any socket-related calls like (fp)Bind or fp(Listen) in the code (FPC 2.3.1). Only fpAccept exists inside of custfcgi.pp which tries to accept connection from StdInputHandle, and this looks somehow cryptic to me. But maybe I am missing something?

Fcgi indeed uses sockets for the communication with the web-server, but
for convenience stdin is used. For a real explanation see here:
http://www.fastcgi.com/drupal/node/6?q=node/22#S2.2

Joost

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: How to use FCGI?

Stootch
OK, thanks, got it working.

Please correct me, if I am wrong, but this approach makes developing and debugging harder, because it is httpd which spawns the application, so to effectively kill the app and replace it with new build I have to restart the httpd (at least with lighttpd which I tested).

I see possible resulutions:

1. Create the application as a standard CGI and convert it to FCGI on deployment
or
2. Make TCustomFCGIApplication's descendant and replace WaitForRequest with own code which binds, listens and accepts connections from httpd. Then, upon compilation, I need only to restart my application.

Am I right?

Dnia 10 lipca 2009 12:33 Joost van der Sluis <[hidden email]> napisał(a):

> Someone here said it didn't work on windows, but I think that's fixed in
> the mean time. Linux should work, further I didn't test.

> Fcgi indeed uses sockets for the communication with the web-server, but
> for convenience stdin is used. For a real explanation see here:
> http://www.fastcgi.com/drupal/node/6?q=node/22#S2.2

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: How to use FCGI?

Joost van der Sluis
Op maandag 13-07-2009 om 11:07 uur [tijdzone +0200], schreef Artur
Stuczyński:

> OK, thanks, got it working.
>
> Please correct me, if I am wrong, but this approach makes developing and debugging harder, because it is httpd which spawns the application, so to effectively kill the app and replace it with new build I have to restart the httpd (at least with lighttpd which I tested).
>
> I see possible resulutions:
>
> 1. Create the application as a standard CGI and convert it to FCGI on deployment
> or
> 2. Make TCustomFCGIApplication's descendant and replace WaitForRequest with own code which binds, listens and accepts connections from httpd. Then, upon compilation, I need only to restart my application.
>
> Am I right?

Easiest is to use the embedded-web-server I've send to this list a month
ago. That way you can debug from within the Lazarus-ide. When you deploy
your application, you can compile as FastCGI. (Switch one unit in your
uses-clausule and you're done)

Joost.

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal