How to install services on OSX

Apr 28, 2008 | Tags: none

If you have read the previous post about installing services on Linux (What, you haven’t? Do it now!), you will have a
rough idea on how init and the rc.d scripts work. On OSX, launchd is the tool that replaces them both. launchd is invoked by the kernel while booting the
system and takes care of managing the processes, just as init does. To interact with launchd there is a tool called launchctl, which will be used in this tutorial.


The daemon scripts are located at /Library/LaunchDaemons. Only the
system administrator has the permissions to write there, so take into account that you will need admin rights to follow the next steps.


Write a properties file (which is a type of file with .plist extension that Apple uses for configuration), in /Library/LaunchDaemons. For example,
let’s say we want the Drupal Stack to be started at boot time. We would create the file /Library/LaunchDaemons/com.bitnami-drupal.service.plist


<?xml version=“1.0” encoding=“UTF-8”?>
<!DOCTYPE plist PUBLIC “-//Apple//DTD PLIST 1.0//EN” “http://www.apple.com/DTDs/PropertyList-1.0.dtd”>
<plist version=“1.0”>
<dict>
  <key>Label</key>
  <string>com.bitnami-drupal.services</string>
  <key>ProgramArguments</key>
  <array>
   <string>INSTALLDIR/ctlscript.sh</string>
   <string>start</string>
  </array>
  <key>UserName</key>
  <string>root</string>
  <key>RunAtLoad</key>
  <true/>
  <key>OnDemand</key>
  <false/>
</dict>
</plist>


Remember to substitute INSTALLDIR with your current installation path!


When you reboot the machine, the servers will be automatically started. Man, that was easy! If you prefer not to reboot,
just use launchctl tool to start the service


launchctl load -w /Library/LaunchDaemons/com.bitnami-drupal.service.plist


To uninstall the service, type


launchctl unload -w /Library/LaunchDaemons/com.bitnami-drupal.service.plist


and delete the properties file
/Library/LaunchDaemons/com.bitnami-drupal.service.plist so that it isn’t launched at boot time.


This is the end of the article. If you have comments or suggestions, please post at the following topic on the forums


http://bitnami.org/forums/forums/27/topics/366

Comments

no comments

New Comment

You need to login/signup to post the comment.

Digg-icon Digg This Story    Reddit-icon Reddit!    Facebook-icon Join Our BitNami Group

Twitter-16x16 Follow Us On Twitter    Add to del.icio.us    Stumbleupon-icon Stumble It!

Back