I wish to load and run a Lisp program in CCL in the background automatically when my Mac (OS 10.9) boots. I have a launchd plist that I've saved to /Library/LaunchDaemons,
<?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.icecreamcomputer</string>
<key>ProgramArguments</key>
<array>
<string>sudo</string>
<string>/Applications/ccl/./dx86cl</string>
<string>-l</string>
<string>/Users/frank/Documents/Lisp/ice-cream-computer/ice-cream-computer.lisp</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
</dict>
</plist>
When I call
launchctl load /Library/LaunchDaemons/com.icecreamcomputer.plist
from the terminal, I can see in top that dx86cl runs for a few seconds, then goes away. Afterward launchd lists the job as having exited. However, if I call
sudo /Applications/ccl/./dx86cl -l /Users/frank/Documents/Lisp/ice-cream-computer/ice-cream-computer.lisp
from the terminal, my program starts up and stays running no problem. What could be causing my launchd job to quit immediately after starting?
Here are entries from /var/log/system.log:
Apr 15 10:01:55 frynseytv.icecreamcomputer.com sudo[34963]: root : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/Applications/ccl/./dx86cl -l /Users/frank/Documents/Lisp/ice-cream-computer/ice-cream-computer.lisp
Apr 15 10:01:58 frynseytv com.apple.launchd[1] (com.icecreamcomputer): Throttling respawn: Will start in 8 seconds
Apr 15 10:02:00 frynseytv com.apple.launchd.peruser.501[306] (com.icecreamcomputer[34965]): open("/var/log/icecreamcomputer.log", ...): 13: Permission denied
Apr 15 10:02:02 frynseytv com.apple.launchd.peruser.501[306] (com.icecreamcomputer): Throttling respawn: Will start in 8 seconds
Apparently it didn't have permission to open a log called "/var/log/icecreamcomputer.log," and indeed no such file or directory exists. Although that seems odd because root/wheel owns /var/log/icecreamcomputer.log, and root runs launchd and the other processes launchd launches, doesn't it? Here's an excerpt from /var/log/icecreamcomputer.log. It shows what normally prints to stdout when icecreamcomputer.lisp loads. What it lacks is logged http server activity, like receiving and fulfilling requests.
Welcome to Clozure Common Lisp Version 1.9-r15759 (DarwinX8664)!
?
==== quicklisp quickstart loaded ====
To continue with installation, evaluate: (quicklisp-quickstart:install)
For installation options, evaluate: (quicklisp-quickstart:help)
To load "hunchentoot":
Load 1 ASDF system:
hunchentoot
; Loading "hunchentoot"
Actually when I tail -f /var/log/icecreamcomputer.log, it continues its cycles of throttling respawns and saying that it fails to write to its log even after I call launchctl unload /Library/LaunchDaemons/com.icecreamcomputer.plist. It only stopped cycling upon server reboot. What gives?
After the restart, I attempted to load the daemon again. No error messages, but launchctl list shows the process has exited, and tailing icecreamcomputer.log showed no activity while I loaded the daemon's plist.