Search code examples
mysqlcoldfusionadobeosx-yosemitelaunchd

Automatically start Adobe Coldfusion in OS X


I am running the latest Apple OS X 10.10(.1) Yosemite, and the latest Adobe Coldfusion 11. Everything works ok, but the server does not startup automatically on startup. I can go into Terminal and use:

cd /Applications/ColdFusion11/cfusion/bin
sudo ./coldfusion start

However the server is not on by default. How do I set it so that it launches every time the computer starts up?


Solution

  • This is the same issue as MySQL suffers. If you go to:

    /Library/StartupItems
    

    You will see that both ColdFusion and MySQL (if you have it installed) have created startup items - however that functionality has been deprecated by Apple (see Mac Developer Library: Startup Items) so the services do not startup automatically as desired. The preferred method is by using Launch Daemons.

    To do so you must create an XML / text file as follows:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
        <key>Label</key> 
        <string>com.coldfusion.startup</string>
        <key>Disabled</key> 
        <false/>
        <key>OnDemand</key> 
        <true/>
        <key>RunAtLoad</key> 
        <true/>
        <key>UserName</key> 
        <string>root</string>
        <key>AbandonProcessGroup</key> 
        <true/>
        <key>ProgramArguments</key>
        <array>
            <string>/Applications/ColdFusion11/cfusion/bin/coldfusion</string>
            <string>start</string>
        </array>
        <key>ProcessType</key> 
        <string>Background</string>
    </dict>
    </plist>
    

    Replace 'root' with a valid admin UserName. This file should then be saved to the following directory, I used the filename 'com.coldfusion.startup.plist':

    /Library/LaunchDaemons
    

    The system may ask for your password to save the file here if you're using Finder to do so.

    Now using Terminal, you must set the appropriate access permissions on the new file you have created, so that it will run properly on startup. Use the following 3 commands:

    sudo chown root /Library/LaunchDaemons/com.coldfusion.startup.plist 
    sudo chgrp wheel /Library/LaunchDaemons/com.coldfusion.startup.plist 
    sudo chmod 644 /Library/LaunchDaemons/com.coldfusion.startup.plist
    

    Finally you should run the new LaunchDaemon once to register it and ensure it runs on startup subsequently:

    sudo launchctl load /Library/LaunchDaemons/com.coldfusion.startup.plist
    

    Now if you restart your system ColdFusion should run automatically. Excellent. I pieced this together from a couple of articles listed below:

    Autostart MySQL Server on Mac OS X Yosemite

    Autostart ColdFusion in OS X Yosemite

    The CF Launch Daemon is only marginally altered to work with CF11 etc. If you use a simpler Launch Daemon it doesn't work. You also need the permissions from the MySQL question - so many thanks to the respective authors.