Long time ago I have created a Powershell script that stops the Apache-service, delete the webserver logs and the start the service again. Have had no issues until recently when the stop-process has started to time out, the well known error "The service did not respond in a timely fashion..".
Well fine, to get around this I updated the script. So very basically explained it now does:
stop-service webserverservice # Check if process is stil alive, and if found using the PID stop-process -id $processPid -force
That should take care of it, if stopping the service times out, well, lets just kill the process. And actually doing the last check twice to ensure that no child process are spawened before killing the main process.
BUT - on some servers, not all, and not always either, the above steps are not waterproofed. When starting the server it says
(OS 10048)Only one usage of each socket address (protocol/network address/port) is normally permitted. : make_sock: could not bind to address 0.0.0.0:80 no listening sockets available, shutting down Unable to open logs
And here is the thing that I cannot explain. Still using Powershell and the netstat equivalent Get-NetTCPConnection
PS C:\temp> Get-NetTCPConnection -LocalPort 80 Get-NetTCPConnection : No MSFT_NetTCPConnection objects found with property 'LocalPort' equal to '80'. Verify the value of the property and retry.
This leaves me with only one option, reboot the server, and then all is fine again.
Anyone seeing something that I do not, which could explain why I get this problem?