Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2009-07

How to use FCGI?

4 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Artur Stuczyński

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

Joost van der Sluis
to Artur Stuczyński

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

Artur Stuczyński
to Joost van der Sluis

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 napisał(a):

Show quoted text 6 lines
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
Joost van der Sluis
to Artur Stuczyński

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

Show quoted text 11 lines
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.