Using strace for failed httpd startup


The other day I was having issues finding out why some of our servers couldn't start the apache service

Upon systemctl start httpd, it would hang for a good 3 minutes or so, and then output the following:

Job for httpd.service failed because the control process exited with error code. See "systemctl status httpd.service" and "journalctl -xe" for details

The citizens of the web would suggest people with this problem to run apachectl configtest, as that would inform you of things like syntax errors in config.
Well we didn't make any changes to any configuration, so I wasn't surprised to find that apachectl configtest also hangs with no output.

In this case you can use try to use strace to get an incredibly dense and verbose output of the command attempts.

Initially I had tried the apache startup command, sudo strace -f sudo systemctl start httpd, but found that it didn't output any particularly useful information after arriving at the hang.

But when trying with the previous configtest command instead, sudo strace -f sudo apachectl configtest, that's when I got:

[pid 23346] connect(9, {sa_family=AF_UNSPEC, sa_data="\0\0\0\0\0\0\0\0\0\0\0\0\0\0"}, 16) = 0
[pid 23346] connect(9, {sa_family=AF_INET, sin_port=htons(80), sin_addr=inet_addr("0.0.0.0")}, 16) = 0
[pid 23346] getsockname(9, {sa_family=AF_INET6, sin6_port=htons(44018), inet_pton(AF_INET6, "::ffff:127.0.0.1", &sin6_addr), sin6_flowinfo=htonl(0), sin6_scope_id=0}, [28]) = 0
[pid 23346] close(9)                    = 0
[pid 23346] stat("/mydirectory/subdirectory/www",

The last line is where it hung, and how I found out that the cause was one of the network drives not being mounted correctly on the web server.

 

 

Back to Reads