Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'The Mac Way' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
The Mac Way
Authored by: thinkyhead on Mar 08, '05 10:03:58PM

I don't know why Apache wouldn't be starting correctly after a power failure on a system with a journaled file system. But if this is a persistent issue then you need to use a more savvy method to restart it than a login item.

The way Apache starts during boot on Mac OS X is through the script /System/Library/StartupItems/Apache/Apache. Whether or not it starts is controlled by the line WEBSERVER=-YES- in /etc/hostconfig. When you click the checkbox in the Sharing panel this line in /etc/hostconfig is set to -YES- and Apache is started with the command SystemStarter start "Web Server".

If you are finding that Apache isn't starting after a power failure, one way to handle it is to make your own StartupItems bundle in the user-configurable /Library/StartupItems folder following Apple's methods (which may or may not work if it runs into the same problem).

But the smartest method by far is to create a cron script that tests for the Apache process every five minutes and runs SystemStarter start "Web Server" as root if it finds no Apache running. In fact here's the script:


#/bin/tcsh
ps -axc | grep httpd || SystemStarter start "Web Server"

By the way the appropriate place to use apachectl graceful is when you're doing something like rolling the logs in a script or editing the httpd.conf file and you want to restart Apache without disrupting connected users.

---
|
| slur was here
|

[ Reply to This | # ]

The Mac Way (10.2)
Authored by: thinkyhead on Mar 08, '05 10:10:11PM
I see your post referred to 10.2 and not 10.3, so I'm not sure if the SystemStarter works the same way. If not you can replace the systemstarter line in the cron script with apachectl start and it will work just fine. The main reason I suggest the SystemStarter method is that it shields you from the variety and version of web server.

---
|
| slur was here
|

[ Reply to This | # ]

The Mac Way
Authored by: derekhed on Mar 09, '05 02:47:57AM

Nice post slur.
Thanks.



[ Reply to This | # ]