Starting Zope Automatically

by Chad Whitacre last modified Dec 30, 2008 03:04 PM
Create two new files and edit one old one.

As expected, Apple uses a variant of the modern BSD startup system. However, instead of '/usr/local/etc/rc.d/', user-defined startup scripts are located in '/Library/StartupItems/'. There are also other slight differences. Fortunately, I was not forced to learn these intricacies, because integrating Zope with it turned out to be fairly trivial.[6]

My strategy was to copy and paste the Apache startup folder and use that as an example::

cp -r /System/Library/StartupItems/Apache /Library/StartupItems/Zope
cd /Library/StartupItems/Zope
rm -r Resources
mv Apache Zope
edit Zope

Edit the shell script, trimming unnecessary conditions and converting from apachectl to zopectl. I've posted mine in an "appendix":appendix-a. Then edit StartupProperties.plist. PropertyList is an Apple-specific format that has both XML and non-XML implementations. If your system is like mine, the Apache plist will be in non-XML format. Somewhere along the line I ended up switching to XML format while trying to get things to work. In the end I don't think it matters, but "my example":appendix-b is in XML.

The last thing you need to do is to edit /etc/hostconfig, and append the following to the end of it::

ZOPESERVER=-YES-

I learned this critical tidbit from "a random how-to on Apple.com":http://docs.info.apple.com/article.html?artnum=107671 (in the last paragraph). At first I thought the value of the 'Provides' key in the "plist file":appendix-b is what drives the service name in /etc/hostconfig. However, now I think that the hostconfig file provides context for the "Zope startup script":appendix-a.[7] In any case, the files as described work for me.

After you edit these three files, bounce your server and see if Zope comes back up on reboot. If it does, then it is time to step back a bit and look at "what we've done with the OS X filesystem":filesystem.

<hr>

Notes

[6] If you want to understand the system, as good a place to start as any is "Start Me Up: Writing and Understanding OS X StartupItems":http://www.macdevcenter.com/pub/a/mac/2003/10/21/startup.html from O'Reilly's Mac DevCenter. This tutorial is nearly great: he makes no mention of /etc/hostconfig, however.

[7] Incidentally, here's another place where the Darwin man pages let me down. Why no manual entry for hostconfig?