Wt application with Apache and mod_fcgid - Address already in use
Added by Simon M over 9 years ago
I try to get my application running with Apache (works with standalone server).
If I try to connect, I get the following error in the apache logs:
[mts@lcm-mts wt]$ sudo tail /var/log/httpd/error_log --lines=40
[Fri Feb 05 16:05:26.273245 2016] [fcgid:warn] [pid 16556] mod_fcgid: process 16639 graceful kill fail, sending SIGKILL
[Mon Feb 08 10:20:49.175478 2016] [mpm_prefork:notice] [pid 16555] AH00170: caught SIGWINCH, shutting down gracefully
[Mon Feb 08 10:20:50.749705 2016] [suexec:notice] [pid 17846] AH01232: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using fe80::250:56ff:fe00:8471. Set the 'ServerName' directive globally to suppress this message
[Mon Feb 08 10:20:50.785701 2016] [auth_digest:notice] [pid 17846] AH01757: generating secret for digest authentication ...
[Mon Feb 08 10:20:50.786360 2016] [lbmethod_heartbeat:notice] [pid 17846] AH02282: No slotmem from mod_heartmonitor
[Mon Feb 08 10:20:50.791301 2016] [mpm_prefork:notice] [pid 17846] AH00163: Apache/2.4.6 (CentOS) mod_fcgid/2.3.9 configured -- resuming normal operations
[Mon Feb 08 10:20:50.791357 2016] [core:notice] [pid 17846] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'
[2016-Feb-08 10:20:54.043941] 17931 - [info] "WServer/wtfcgi: initializing relay server"
[2016-Feb-08 10:20:54.044513] 17931 - [info] "config: reading Wt config file: /etc/wt/wt_config.xml (location = '/var/www/wt/MyApp.wt')"
[2016-Feb-08 10:20:54.045192] 17931 - [info] "wtfcgi: spawned session process: pid = 17935"
[2016-Feb-08 10:20:54.045359] 17931 - [info] "wtfcgi: reading FastCGI stream from stdin"
terminate called after throwing an instance of 'boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::system::system_error> >'
what(): bind: Address already in use
[2016-Feb-08 10:21:04.125555] 17931 - [error] "wtfcgi: connect(): No such file or directory"
[2016-Feb-08 10:21:04.125672] 17931 - [info] "wtfcgi: giving up on session: (/var/run/wt/server-17935)"
[2016-Feb-08 10:21:04.125760] 17931 - [error] "wtfcgi: session process 17935 not responding ?"
[2016-Feb-08 10:21:14.238825] 17931 - [error] "wtfcgi: connect(): No such file or directory"
[2016-Feb-08 10:21:14.238971] 17931 - [info] "wtfcgi: giving up on session: (/var/run/wt/server-17935)"
[2016-Feb-08 10:21:14.239112] 17931 - [error] "wtfcgi: session process 17935 not responding ?"
[2016-Feb-08 10:21:24.353211] 17931 - [error] "wtfcgi: connect(): No such file or directory"
[2016-Feb-08 10:21:24.353308] 17931 - [info] "wtfcgi: giving up on session: (/var/run/wt/server-17935)"
[2016-Feb-08 10:21:24.353388] 17931 - [error] "wtfcgi: session process 17935 not responding ?"
[Mon Feb 08 10:21:34.034464 2016] [fcgid:warn] [pid 17849] [client 127.0.0.1:36463] mod_fcgid: read data timeout in 40 seconds
[Mon Feb 08 10:21:34.034548 2016] [core:error] [pid 17849] [client 127.0.0.1:36463] End of script output before headers: MyApp.wt
[2016-Feb-08 10:21:34.505165] 17931 - [error] "wtfcgi: connect(): No such file or directory"
[2016-Feb-08 10:21:34.505322] 17931 - [info] "wtfcgi: giving up on session: (/var/run/wt/server-17935)"
[2016-Feb-08 10:21:34.505428] 17931 - [error] "wtfcgi: session process 17935 not responding ?"
[2016-Feb-08 10:21:36.042816] 17931 - [info] "wtfcgi: shutdown (caught SIGTERM)"
[Mon Feb 08 10:21:42.048820 2016] [fcgid:warn] [pid 17848] mod_fcgid: process 17931 graceful kill fail, sending SIGKILL
I have the following wt.conf:
<IfModule mod_fcgid.c>
NameVirtualHost *:80
SocketPath /var/lib/apache2/fcgid/sock
MaxProcessCount 10
<VirtualHost *:80>
AddHandler fcgid-script .wt
DirectoryIndex MyApp.wt
<Directory /var/www/wt/>
AllowOverride Indexes
Allow from all
Options +ExecCGI -Indexes
</Directory>
IdleTimeout -1
ProcessLifeTime -1
FcgidInitialEnv WT_APP_ROOT /var/www/wt/approot/
DefaultMaxClassProcessCount 10
DefaultMinClassProcessCount 1
</VirtualHost>
</IfModule>
I don't understand why bind() fails. This happens also, when I start Apache completely new and make sure there are no processes left. And I don't know which file cannot be found.
Any suggestions?
Thanks!
Replies (7)
RE: Wt application with Apache and mod_fcgid - Address already in use - Added by Louis Hoefler over 9 years ago
First make sure there is no autospawned fcgi deamon left. You can control the deamons over /usr/sbin/fcgi-pm you may need to restart this deamon depending on your Distribution.
You could also try to find out which programm uses a socket with netstat -tulpen /proc/net/tcp is the sysfile for that.
Or in you case netstat ---all ---program | grep 'port'
Then i should avice you that you may configure your server without using fcgi-pm and manage the fcgi deamon yourselve
Apache 2.4+ config:
...
Alias "/css/" "/home/xxx/css/"
Alias "/icons/" "/home/xxx/icons/"
Alias "/resources/" "/home/xxx/resources/"
Alias "/img/" "/home/xxx/img/"
FastCgiExternalServer /home/xxx/index.fcgi -host xxx:port -idle-timeout 200
##Currently static autostart gives chdir permission error see WT_APP_ROOT and maybe change paths within your programm
#FastCgiServer /home/xxx/index.fcgi -user xxx -group xxx-port port -idle-timeout 200 -initial-env WT_APP_ROOT=/home/xxx
ScriptAlias /index.fcgi "/home/xxx/index.fcgi"
# SetHandler cgi-script
AddHandler cgi-script .cgi .pl
AddHandler fastcgi-script .fcg .fcgi .fpl
Options FollowSymLinks ExecCGI
Require all granted
... virtual end
Note: that you need to maybe need to set your WT_APP_ROOT=/home/xxx environment variable.
It depedns how wt was configured and installed.
RE: Wt application with Apache and mod_fcgid - Address already in use - Added by Simon M over 9 years ago
Thanks for your answer.
As I'm using fcgi not FastCGI it seems there's no fcgi-pm available?
RE: Wt application with Apache and mod_fcgid - Address already in use - Added by Louis Hoefler over 9 years ago
Thats true. fcgi-pm is installed with libapache2-mod-fastcgi. I dont know how fcgid handles process management. You may have to dig into the fcgid documentation.
RE: Wt application with Apache and mod_fcgid - Address already in use - Added by Koen Deforche over 9 years ago
Hey,
Don you have the /var/run/wt directory with correct permissions for Apache to write?
Koen
RE: Wt application with Apache and mod_fcgid - Address already in use - Added by Simon M over 9 years ago
Hi,
Koen Deforche wrote:
Don you have the /var/run/wt directory with correct permissions for Apache to write?
Yes, I do. Fixed already the "Permissions denied" errors.
RE: Wt application with Apache and mod_fcgid - Address already in use - Added by Koen Deforche over 9 years ago
How does your main() look like? Are you forwarding all argc, argv arguments to Wt?
RE: Wt application with Apache and mod_fcgid - Address already in use - Added by Simon M over 9 years ago
Found the issue.
My application uses a library, which opens an UDP port (and also uses boost::asio).
So mod_fcgi spawns multiple instances and therefor the UDP port is opened multiple times, which of course doesn't work.
Now I have to find a solution to overcome this issue.