0

I am trying to setup Yaws (installed via Homebrew) to start automatically under OS X Yosemite using the following PLIST:

    <?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>ca.seidlitz.yaws</string>
        <key>ProgramArguments</key>
        <array>
                <string>sh</string>
                <string>-c</string>
                <string>/usr/local/Cellar/yaws/1.98/bin/yaws --daemon --conf /usr/local/Cellar/yaws/1.98/etc/yaws/yaws.conf</string>
        </array>
        <key>RunAtLoad</key>
        <true/>
        <key>WorkingDirectory</key>
        <string>/usr/local/opt/yaws</string>
        <key>StandardOutPath</key>
        <string>/tmp/yaws.log</string>
        <key>StandardErrorPath</key>
        <string>/tmp/yaws_err.log</string>
</dict>
</plist>

I tried to load this plist using sudo launchctl load /Library/LaunchDaemons/ca.seidlitz.yaws.plist
but with no luck. I don't get any error in /var/system.log, while the /tmp/yaws.log contains this error: "1> *** Terminating erlang (nonode@nohost)"

I also tried running it as daemon and in interactive mode. Daemon doesn't generate any errors in the log file but Yaws is not running.

Can anyone spot any issues with the plist?

Alex Popov
  • 3,726
  • 1
  • 17
  • 20

1 Answers1

1

You should make the /usr/local/Cellar/yaws/1.98/bin/yaws script executable if it isn't already, get rid of the sh -c invocation, and properly declare the yaws script and its arguments as separate strings, all like this:

<?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>ca.seidlitz.yaws</string>
        <key>ProgramArguments</key>
        <array>
                <string>/usr/local/Cellar/yaws/1.98/bin/yaws</string>
                <string>--daemon</string>
                <string>--conf</string>
                <string>/usr/local/Cellar/yaws/1.98/etc/yaws/yaws.conf</string>
        </array>
        <key>RunAtLoad</key>
        <true/>
        <key>WorkingDirectory</key>
        <string>/tmp</string>
        <key>StandardOutPath</key>
        <string>/tmp/yaws.log</string>
        <key>StandardErrorPath</key>
        <string>/tmp/yaws_err.log</string>
</dict>
</plist>
Steve Vinoski
  • 19,847
  • 3
  • 31
  • 46
  • Thanks, Steve. I verified that the yaws script is executable and modified the plist per your example, but Yaws still doesn't run. There is nothing written to the log files in /tmp directory. I will try dtrace to check for any permission issues. – Alex Popov Nov 12 '14 at 05:25
  • It's not clear from your question whether running it in interactive mode worked. If it's not working in interactive mode, I recommend getting that working first. – Steve Vinoski Nov 13 '14 at 02:41
  • Yes, yaws runs fine both in interactive mode and demonized from the shell. The only issue is running it from the LaunchDaemon plist. Now that I have a proper plist, I am trying to troubleshoot if there are issues with file permissions and such. At this point it looks like some local issue. Thanks again for your help. – Alex Popov Nov 13 '14 at 19:19
  • Thanks, Steve. I got launchd working with your advice. Yaws works, but now `yaws --status` or `--stats` display `No yaws system responds` either from my account or when run by root. `yaws --ls` also shows that the system is stopped. The control file is created by `root` under `/tmp/.yaws/yaws/default/CTL`. What's the proper way to interact with daemonized system started from launchd? (Shall I repost this as a separate question for clarity?) – Alex Popov Dec 11 '14 at 02:38
  • The status checking expects to find control information under the user's home directory by default. You might try first setting the OS environment variable `YAWSHOME=/tmp` and then running the `yaws --status` command. – Steve Vinoski Dec 11 '14 at 02:47