[Lazarus] Developing with fcl-web

Michael Van Canneyt michael at freepascal.org
Sat Jul 26 14:47:07 CEST 2014



On Sat, 26 Jul 2014, Reimar Grabowski wrote:

> Hi,
>
> first of all, sorry if the information is out there, but I did not find anything usefull to help me along.
>
> I need to build a server-side application (fcgi is my choice) that gets send some json, processes it and communicates with a mysql database, simple enough.
> Looks like all this is perfectly doable without any problems with Lazarus and fcl-web, at least the 'gets send some json and processes it'-part I have already done for another project.
> But it was a pain to develop.
> For such kind of projects I am used to Java and development in Eclipse.
> My major problem with Lazarus is where is my server?

That depends.

> In Eclipse I just configure my Tomcat or whatever other container I want to use, press 'run on server' and voila, eclipse starts Tomcat and my application with full logging working inside the IDE to be found at 'http://localhost:8080/myapp'.
> If I need breakpoints or single stepping, I just start the server in debug mode and all is well.
> So how do I configure Lazarus to do about the same?

It depends on how you set it up.

> I found some mentioning of fpembweb or lazaruswebdesign packages but nothing concrete about where to find or how to use them.
> Surely some of you guys do such kind of development with Lazarus and I cannot believe that everybody runs a local apache and copies his executable around after every compile (my apache is on a VM which made it even more work to copy the files around and there was no debugging capability to speak of).
> So it boils down to let Lazarus run the fcgi app (can be another app type if it is easy to switch it to fcgi for deployment) on an (embedded) server, with logging output shown in the IDE and the option to use a debugger with breakpoints and single stepping.

There are 2 options:

1. Use embedded server to do the debugging; that part is easy, it's like running a normal executable.
    You don't need apache for this.

2. You can run the fastcgi server if you use mod_fastcgi.so, but then you must use the ExternalFastCGIServer option, and configure the fastcgi application to listen on this port:

In Apache, configure
FastCgiExternalServer /home/michael/public_html/testht -host 127.0.0.1:10020 -idle-timeout 3 -flush
Here 10020 is the port to listen on, and /home/michael/public_html/testht is the URL that will be the 'base' url for your fastcgi app.


In that case, your fastcgi application must be configured to listen on the same port:
Set
Application.Port:=10020;
in the project source file.

Restart apache, run your executable, and do a request through the browser. That's it.

Note that you cannot do this with the mod_fcgid module. I do believe that in Apache 2.4, mod_proxy can handle this situation, but I haven't tried yet.

Michael.




More information about the Lazarus mailing list