We do frequent deployments using udeploy and we have there a shell script to restart the apache http server as the last task. Script is simple:-
cd bin_path
sudo ./apachectl -k stop
sleep 5
sudo ./apachectl start
The problem here is that sometimes the stop command takes longer than 5 seconds, which will cause the start to fail with a "server already running" message. After the start fails, the stop will complete, which leaves the server down. Hence looking for a better solution to make sure that server is fully stopped before the start is excecuted.