|Summary:||Apache fails to start if previously crashed then restarted with same PID|
|Product:||Apache httpd-2||Reporter:||Val <valentin.bremond>|
|Component:||Core||Assignee:||Apache HTTPD Bugs Mailing List <bugs>|
Same PID can't be running
Description Val 2016-10-17 07:38:13 UTC
Created attachment 34377 [details] Proposed patch Overview: This problem occurs mainly with Docker (or other containerization technologies) with the main process being Apache because it always have the same PID (PID 1). The issue arises when the container (or the process inside) fails without proper error handling (kill -9 for example). In this case, Apache can't remove its PID file (which contains "1"). Once the container is restarted, Apache restarts inside with PID 1 but fails when reading the PID file which also contains "1" (with error: "http (pid 1) already running"). Steps to Reproduce: * docker run -it httpd:latest bash * get current PID counter: `ps -ef`, then get "ps" current PID (let's assume it's 5) * set this PID + 1 to logs/httpd.pid: `echo 6 > logs/httpd.pid` * try to run Apache: it fails with: httpd (pid 6) already running Actual Results: Apache fails to start although there is no reason to fail. Expected Results: Apache can realize the PID in the file is actually himself and can then proceed to launch. Build Date & Hardware: 2016-10-14 on Linux (CentOS 7.2.1511, Docker 1.12.0, Apache from 2.4.6 to 2.4.23)
Comment 1 Yann Ylavic 2016-10-17 08:25:43 UTC
Created attachment 34378 [details] Same PID can't be running Thanks for the report (and patch). This other approach handles the case as if httpd were not running (it can't be), no particular logging (possibly obscure, especially if some stop is asked). There is still later message about "pid file %s overwritten -- Unclean shutdown of previous Apache run?", which I think is enough as notice for (re)starts. Does it work for you?
Comment 2 Val 2016-10-17 09:26:46 UTC
Hello, Yep it works too. Your patch is indeed simpler but still understandable. OK for me!
Comment 3 Yann Ylavic 2016-10-21 21:49:17 UTC
Committed in r1766160 and proposed for backport to 2.4.x.