[FASTCGI] Java FastCGI + Lighttpd

Scritch scritch at gmx.de
Tue May 11 07:02:45 EDT 2010


Hello Everybody,

I am currently writing a small script. Because I found a nice Lib that 
does 90% of my work, I chose Java.

I wrote my mini app and installed it as a CGI script (mod_cgi). In 
Lighttpd. It worked fine.

Because the Java VM startup time takes some time ((overall response time 
 > 1sec), I now want to change my app to FastCGI.

So I downloaded the FastCGI java apps, and changed my code accordingly. 
Then I configured lighty:

fastcgi.server = (
"WerderWebcam.link" =>
(( "host" => "127.0.0.1",
"port" => 10260,
"bin-path" => "/bin/werder_jar",
"max-procs" => 1
))
)

werder_jar is my wrapper script that starts my java class:

java -Xdebug 
-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=9717 
-DFCGI_PORT=10260 -jar /var/www/WerderWebcam.jar

This does not work because my app immediately exits. With debugging I 
found out that the reason is because the FastCGI classes can not install 
themselves because the port is already used: "java.io.IOException: Port 
already in use".

Next I checked which processes are blocking the port. To my surprise, I 
found out that my own script/app obviously blocks the port: (Found this 
by blocking my app in the debugger and thus preventing it from exiting)

"lsof | grep 10260" gives me:

werder_ja 5908 www-data 0u IPv4 888843 TCP localhost:10260 (LISTEN)
java 5909 www-data 0u IPv4 888843 TCP localhost:10260 (LISTEN)

How can such things happen? How does lighty start my script that it and 
its subprocesses are automatically listening on my FCGI port?

This seems to be independent from the HTTP server. This post:

http://software.itags.org/apache/46290/

indicates that Apache shows the same behavior.

Any ideas for help? How can I get the FastCGI classes to work?


More information about the FastCGI-developers mailing list