Control Panel doesn't delete httpd.pid when stopping Apache

Problems with the Windows version of XAMPP, questions, comments, and anything related.

Control Panel doesn't delete httpd.pid when stopping Apache

Postby TomXampp » 12. March 2015 04:31

I'm using the current version of XAMPP (5.6.3) on Windows 8.1, and the Apache error.log reports this after each session:

Code: Select all
... [core:warn] ... AH00098: pid file C:/xampp/apache/logs/httpd.pid overwritten -- Unclean shutdown of previous Apache run?


I only have Apache, Mysql, and Tomcat installed. The httpd.pid is simply not being deleted by XAMPP at the end of a session. To eliminate other possible causes, I did a fresh installation of the current XAMPP on a different computer (with Windows 8.1) and only installed Apache and Mysql. When I use the XAMPP control panel (v3.2.1), the httpd.pid is created in the location indicated above when I press the [Start] button and Apache loads, but when I then press the [Stop] button, the httpd.pid is not deleted.

HOWEVER:

If--instead--I click on [Shell], which provides a command prompt, and I then enter:

apache_start

...it starts Apache using the apache_start.bat file. The XAMPP control panel shows that Apache is running, and displays the PIDs and ports being used; the control panel's [Start] button accordingly changes to [Stop] so that--if I wish--stop Apache by pressing that button.

But here's the proof that the problem is with the control panel:

If I press the [Stop] button after initiating Apache using the apache_start.bat file at the prompt, the httpd.pid is *NOT* deleted.

On the other hand, if I simply close the CMD window in which I ran the apache_start.bat file to start Apache, THE HTTPD.PID *IS* DELETED.

I've studied the batch files that are called with you use the apache_start.bat file to initialize Apache, and they are designed to delete the httpd.pid file at the end of processing. And, as I just described, the file is in fact deleted when you terminate the session by closing the CMD window (which is a real hackish way to do it, but that's what XAMPP instructs you to do; the batch-file start-up process should work differently; I consider that an embarrassing design flaw). Be that as it may, this does prove that the XAMPP control panel is the culprit.

I've combed the internet looking for a resolution to this problem, which has affected a lot of people, and the typical answer is "one of the DLLs in the PHP.INI file needs to be commented out." That's simply not true; the problem is very simply that the XAMPP control panel's [Stop] procedure has a coding error.

I had hoped that the control panel merely ran the batch files, and that if I found the correct batch file, I could edit it to delete the httpd.pid file at the end of processing, but the batch files are in fact constructed to do that very thing, and the Control Panel isn't invoking them; it's performing the Start-up and Shut-down process with its own processes.

Could the person responsible for the coding of the Control Panel please be alerted that there's an oversight in its code that's preventing the httpd.pid file from being deleted during the Stop procedure for Apache? It's not in the Apache engine, for the batch file method of starting and stopping does in fact delete the httpd.pid file. I would be happy to beta-test the revised Control Panel EXE.

Please comment...

Many thanks,
Tom
TomXampp
 
Posts: 28
Joined: 12. March 2015 03:58
Operating System: Windows 8.1

Re: Control Panel doesn't delete httpd.pid when stopping Apa

Postby TomXampp » 12. March 2015 04:43

More info:

When using the apache_start batch file routine to initiate and close Apache, these three lines are written to the error.log file that are NOT written to that file when starting and stopping are performed with the Control Panel:

Code: Select all
[Wed Mar 11 22:39:19.033927 2015] [mpm_winnt:notice] [pid 5912:tid 376] AH00422: Parent: Received shutdown signal -- Shutting down the server.
[Wed Mar 11 22:39:21.065725 2015] [mpm_winnt:notice] [pid 4940:tid 392] AH00364: Child: All worker threads have exited.
[Wed Mar 11 22:39:21.237599 2015] [mpm_winnt:notice] [pid 5912:tid 376] AH00430: Parent: Child process 4940 exited successfully.


More proof that the Control Panel is malfunctioning.
TomXampp
 
Posts: 28
Joined: 12. March 2015 03:58
Operating System: Windows 8.1

Re: Control Panel doesn't delete httpd.pid when stopping Apa

Postby gsmith » 12. March 2015 07:40

I wouldn't say it's missfunctioning, it's just not pretty. A quick browse through the control pannels code looks like if it's not a service, it uses TerminateProcess(pid). TerminateProcess does just that, kills the process so Apache cannot run it's cleanups before exiting. It the same as if you went into the task manager in windows, chose a process and clicked the end process button. If you did that to say a word document you had not saved changes in awhile, you would lose the changes.

If you look at apache_close.bat, you will notice it uses a little utility called pv, pv -f -k httpd.exe -q. This basically does exactly the same, the only thing it does do is delete the pid file if it exists, and I'm sure it does. Either way I fail to see how either of these two scenarios could produce this output in the error log;
[Wed Mar 11 22:39:19.033927 2015] [mpm_winnt:notice] [pid 5912:tid 376] AH00422: Parent: Received shutdown signal -- Shutting down the server.

On the other hand, if you use apache_start.bat and then close the console window, it could because that is the same as using Ctrl+c which does signal Apache to shutdown normally.
gsmith
 
Posts: 194
Joined: 29. November 2013 18:04
Location: San Diego
XAMPP version: 0.0.0
Operating System: Win XP to 2012R2/VS 6,9,11,14

Re: Control Panel doesn't delete httpd.pid when stopping Apa

Postby TomXampp » 12. March 2015 08:19

I've been experimenting more, and I've discovered that if I start the Service Modules for both Apache and MYSQL *first*, and then start and stop Apache and MYSQL with their respective [Start] buttons, then not only is the httpd.pid file deleted properly upon stopping the Apache, but error messages about mismatched entries between the ib_logfiles and the ibdata file that were being reported in mysqlerror.log also vanish.

So...it seems if I want error-free log files, I should start the Service Modules for Apache and MYSQL first and then (seemingly redundantly) start Apache and MYSQL with the Control Panel [Start/Stop] controls.

The reason this became important to me is because I'm trying to debug a mod_rewrite problem in .htaccess, and someone responding to my questions about it on another site insisted that the error messages I was receiving in the Apache error log and the MYSQL error log were perhaps indicative of the underlying problem.

Now that I've taken care of this (except for asking what are the purposes of the Service Modules...could you clarify that?), I'll ask the mod_rewrite question here as a separate question.

Thanks for your help!
TomXampp
 
Posts: 28
Joined: 12. March 2015 03:58
Operating System: Windows 8.1

Re: Control Panel doesn't delete httpd.pid when stopping Apa

Postby gsmith » 12. March 2015 09:00

Both those can be run as a Windows Service. It's actually the best way to run them.
See in Windows: Control Panel -> Administrative Tools -> Services

Windows Services run automatically at startup whether at or not you are logged into the desktop, as most servers are run, no one logged in. However, if you do not like the sound of that you can change them to not start automatically, but since they are already installed you should be able to just click start on the control panel for each.

When the services are installed, you should have both Apache2.4 and MySQL listed in the services window point mentioned above.

In the Services windows, right click on a service name and choose Properties. Find Startup Type and choose Manual from the drop-down menu to the right.
gsmith
 
Posts: 194
Joined: 29. November 2013 18:04
Location: San Diego
XAMPP version: 0.0.0
Operating System: Win XP to 2012R2/VS 6,9,11,14


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 45 guests

cron