Apache 2 boot script: httpd_2

DirectAdmin Support

Administrator
Staff member
Joined
Feb 27, 2003
Messages
8,500
Hello,

I've updated the httpd_2 boot script (for apache 2), saved into /etc/init.d/httpd for new installs.
A report suspected it's older restart method may have been the cause of some non-clearing semaphore issues.
I've tested the new script for a day our our live init.d test box, without any issues.

Next time you ./build update; ./build apache, it should automatically install the new script.

For anyone interested, here's the diff:
http://files1.directadmin.com/services/custombuild/httpd_2.diff

New file:
http://files1.directadmin.com/services/custombuild/httpd_2

Old file:
http://files1.directadmin.com/services/custombuild/httpd_2.old.2

Please let us know if you run into any issues with it!

John
 
A report suspected it's older restart method may have been the cause of some non-clearing semaphore issues.

nice !

I had exactly this problem but only on new servers under centos 7
 
I did still have some problems with starting apache on Centos 7 with systemd (with cloudlinux!), a 'systemctl start apache' would wait forever to start apache. I noticed the service type has changed from to notify, it appears it waits on this notification from apache forever, might be a cloudlinux thing. I switched back to the forking type and everything was fine again. Sorry, I can't test it any further since it happened in the middle of deploying the server from test to production, and no longer have a server I can test this on. Maybe someone with cloudlinux could test this and see if it really is a problem or something funny in my setup.
 
I did still have some problems with starting apache on Centos 7 with systemd (with cloudlinux!), a 'systemctl start apache' would wait forever to start apache. I noticed the service type has changed from to notify, it appears it waits on this notification from apache forever, might be a cloudlinux thing. I switched back to the forking type and everything was fine again. Sorry, I can't test it any further since it happened in the middle of deploying the server from test to production, and no longer have a server I can test this on. Maybe someone with cloudlinux could test this and see if it really is a problem or something funny in my setup.

It was related to a bug, which occurred in "./build rewrite_confs", CB 2.0 rev. <1547. Please run the following to fix it for now and do not run rewrite_confs until your CB 2.0 is updated to rev. 1547:
Code:
echo "LoadModule        systemd_module          /usr/lib/apache/mod_systemd.so" >> /etc/httpd/conf/extra/httpd-phpmodules.conf
 
There seem to be an issue, not sure if it is related to the new boot script or apache 2.4.20 (but i think its the boot script).

We have seen multiple reports where each page request presents a different output. For example:
- a user added a domain and hours later apache shows "Apache is working correctly", CTRL+F5 and the website is shown, CTRL+F5 and "Apache is working correctly", etc. Also www.domain.ext and domain.ext show different output (www.domain.ext shows the website and without www shows "Apache is working correctly", tested at the same moment).
- The apache status page shows server uptime 4 days X hours etc, CTRL+F5 and now the server uptime is 5 days Y hours, CTRL+F5 server uptime is 5 seconds.

Conclusion: each apache worker/thread is showing his own "reality". When all Apache processes are killed through killall -9 httpd and Apache is started again everything functions correctly. This issue is seen on multiple servers.

This output shows the existence of old httpd processes:

[root@<server> ~]# service httpd stop
Stopping httpd: [ OK ]

Apache is stopped now, but apparantly there are still processes, even old ones from 25 and 26 may (remember the 4 days and 5 days old status page?)

[root@<server> ~]# ps aux | grep http
root 2802 0.0 0.0 72920 2084 ? Ss May26 0:35 /usr/sbin/httpd
root 4399 0.0 0.0 72920 512 ? Ss May25 0:41 /usr/sbin/httpd
apache 7562 0.1 0.4 1734780 17476 ? Sl 13:43 0:00 /usr/sbin/httpd
apache 7621 0.3 0.5 1735084 20588 ? Sl 13:43 0:01 /usr/sbin/httpd
apache 9074 0.3 0.4 1734528 18300 ? Sl 13:47 0:00 /usr/sbin/httpd
apache 9513 0.2 0.5 1735192 22244 ? Sl 09:42 0:41 /usr/sbin/httpd
root 10944 0.0 0.0 103372 920 pts/1 S+ 13:50 0:00 grep http

Maybe DirectAdmin restarted apache directly, lets stop it again


[root@<server> ~]# service httpd stop
Stopping httpd: [FAILED]

Apache really seems to be stopped?

[root@<server> ~]# ps aux | grep http
root 2802 0.0 0.0 72920 2084 ? Ss May26 0:35 /usr/sbin/httpd
root 4399 0.0 0.0 72920 512 ? Ss May25 0:41 /usr/sbin/httpd
apache 7562 0.1 0.4 1734780 17592 ? Sl 13:43 0:00 /usr/sbin/httpd
apache 7621 0.2 0.5 1735084 20596 ? Sl 13:43 0:01 /usr/sbin/httpd
apache 9074 0.3 0.4 1734528 18316 ? Sl 13:47 0:00 /usr/sbin/httpd
apache 9513 0.2 0.5 1735192 22272 ? Sl 09:42 0:41 /usr/sbin/httpd
root 10972 0.0 0.0 103372 920 pts/1 S+ 13:50 0:00 grep http

Still the same processes, lets kill it all

[root@<server> ~]# killall -9 httpd
[root@<server> ~]# killall -9 httpd
httpd: no process killed
[root@<server> ~]# service httpd restart
Stopping httpd: [FAILED]
Starting httpd: AH00112: Warning: DocumentRoot [<subdomain>] does not exist
AH00112: Warning: DocumentRoot [<subdomain>] does not exist
[ OK ]
[root@<server> ~]# ps aux | grep http
root 11006 1.8 0.3 72920 13768 ? Ss 13:50 0:00 /usr/sbin/httpd
apache 11008 1.2 0.4 1734200 17040 ? Sl 13:50 0:00 /usr/sbin/httpd
apache 11017 0.5 0.3 1144376 14436 ? Sl 13:50 0:00 /usr/sbin/httpd
apache 11056 0.0 0.3 1013304 13904 ? Sl 13:50 0:00 /usr/sbin/httpd
apache 11078 0.7 0.3 1406520 14420 ? Sl 13:50 0:00 /usr/sbin/httpd
apache 11345 1.2 0.4 1734348 17360 ? Sl 13:50 0:00 /usr/sbin/httpd
root 11419 0.0 0.0 103368 912 pts/1 S+ 13:50 0:00 grep http

Only new processes, and the issue with different "worlds" is also fixed
 
If not, you could always try the older boot script again:
Code:
wget -O /etc/init.d/httpd http://files.directadmin.com/services/custombuild/httpd_2.old.2
to see if that has any effect.
We stopped using it because it was a little bit agressive with the httpd process, causing some reports of uncleared semaphors, which eventually filled up and prevented apache from starting at all.

John
 
If not, you could always try the older boot script again:
Code:
wget -O /etc/init.d/httpd http://files.directadmin.com/services/custombuild/httpd_2.old.2
to see if that has any effect.
We stopped using it because it was a little bit agressive with the httpd process, causing some reports of uncleared semaphors, which eventually filled up and prevented apache from starting at all.

John
Hi John,

Just tested it and the old script fixes the problem (the old lines are old processess).

[root@server ~]# ps aux | grep http
root 14609 0.0 0.4 97476 38320 ? Ss 10:11 0:00 /usr/sbin/httpd
apache 14889 0.2 0.6 2457308 51516 ? Sl 10:11 0:02 /usr/sbin/httpd
apache 15461 0.4 0.6 2293444 53336 ? Sl 10:11 0:02 /usr/sbin/httpd

root 19608 5.8 0.4 97476 38324 ? Ss 10:22 0:00 /usr/sbin/httpd
apache 19610 0.7 0.4 1265200 38500 ? Sl 10:22 0:00 /usr/sbin/httpd
apache 19694 0.0 0.4 851496 36964 ? Sl 10:22 0:00 /usr/sbin/httpd
apache 19763 0.5 0.4 1310248 39004 ? Sl 10:22 0:00 /usr/sbin/httpd
apache 19831 0.2 0.0 0 0 ? Z 10:22 0:00 [httpd] <defunct>
apache 19967 0.0 0.4 1048104 38240 ? Sl 10:22 0:00 /usr/sbin/httpd
root 20048 0.0 0.0 103380 900 pts/0 S+ 10:22 0:00 grep http

[root@server ~]# service httpd restart
Stopping httpd: [ OK ]
Starting httpd: [ OK ]

[root@server ~]# ps aux | grep http
root 14609 0.0 0.4 97476 38320 ? Ss 10:11 0:00 /usr/sbin/httpd
apache 14889 0.2 0.6 2457308 51516 ? Sl 10:11 0:02 /usr/sbin/httpd
apache 15461 0.3 0.6 2293444 53340 ? Sl 10:11 0:02 /usr/sbin/httpd

root 20080 15.0 0.4 97476 38320 ? Ss 10:22 0:00 /usr/sbin/httpd
apache 20082 0.0 0.4 1212008 38460 ? Sl 10:22 0:00 /usr/sbin/httpd
apache 20166 0.0 0.4 851496 36940 ? Sl 10:22 0:00 /usr/sbin/httpd
apache 20234 0.0 0.4 851496 36940 ? Sl 10:22 0:00 /usr/sbin/httpd
apache 20303 0.0 0.4 851496 36940 ? Sl 10:22 0:00 /usr/sbin/httpd
apache 20371 0.0 0.4 851496 36940 ? Sl 10:22 0:00 /usr/sbin/httpd
apache 20439 0.0 0.4 851496 36944 ? Sl 10:22 0:00 /usr/sbin/httpd
root 20508 0.0 0.0 103380 896 pts/0 S+ 10:22 0:00 grep http

[root@server ~]# wget -O /etc/init.d/httpd http://files.directadmin.com/services/custombuild/httpd_2.old.2
--2016-08-03 10:23:02-- http://files.directadmin.com/services/custombuild/httpd_2.old.2
Resolving files.directadmin.com... 69.162.69.58, 208.167.226.3, 216.144.254.90
Connecting to files.directadmin.com|69.162.69.58|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2914 (2.8K)
Saving to: “/etc/init.d/httpd”

100%[===================================================================================================================================================================================================>] 2,914 --.-K/s in 0s

2016-08-03 10:23:03 (155 MB/s) - “/etc/init.d/httpd” saved [2914/2914]

[root@server ~]# service httpd restart
Stopping httpd: [ OK ]
Remaining processes: 14609 14889 15461 20903
Stopping httpd: [ OK ]
Starting httpd:

[root@server ~]# ps aux | grep http
root 21198 8.0 0.4 97476 38316 ? Ss 10:23 0:00 /usr/sbin/httpd -k start -DSSL
apache 21200 1.3 0.5 2063976 40188 ? Sl 10:23 0:00 /usr/sbin/httpd -k start -DSSL
apache 21284 0.6 0.4 1375784 39336 ? Sl 10:23 0:00 /usr/sbin/httpd -k start -DSSL
apache 21352 1.0 0.5 1637928 39632 ? Sl 10:23 0:00 /usr/sbin/httpd -k start -DSSL
apache 21420 1.0 0.5 1637928 39784 ? Sl 10:23 0:00 /usr/sbin/httpd -k start -DSSL
apache 21488 1.0 0.4 1441320 39240 ? Sl 10:23 0:00 /usr/sbin/httpd -k start -DSSL
apache 21556 0.0 0.4 917032 38128 ? Sl 10:23 0:00 /usr/sbin/httpd -k start -DSSL
root 21627 0.0 0.0 103376 892 pts/0 S+ 10:23 0:00 grep http


Maybe it is an idea to adapt the old boot script and put the following line in the start section (or after the kill in the end section):

for i in `ipcs -s | awk '/httpd/ {print $2}'`; do (ipcrm -s $i); done

This will remove all semaphores before the start of apache, this way the semaphores won't fill up.
 
Back
Top