Autostart on MacOS
buzink opened this issue · 1 comments
buzink commented
Is there any way to run frontail as a service on MacOS? I installed frontail through npm (and node-js through homebrew) and made the following launchctl file:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs>
<plist version="1.0">
<dict>
<key>Label</key>
<string>frontail.openhab.logs</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/lib/node_modules/frontail/bin/frontail</string>
<string>-d</string>
<string>--pid-path /tmp/frontail.pid</string>
<string>/Users/buzink/openhab/userdata/logs/*.log</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<false/>
<key>StandardErrorPath</key>
<string>/tmp/frontail.openhab.logs.err</string>
<key>StandardOutPath</key>
<string>/tmp/frontail.openhab.logs.out</string>
<key>WorkingDirectory</key>
<string>/usr/local/lib/node_modules/frontail/</string>
</dict>
</plist>
I get the following error:
env: node: No such file or directory
The same command given directly in the shell works fine.
What am I doing wrong?
buzink commented
Solved it. The problem was the env path to /usr/local/bin/ was missing. I don't know how to set that in the launchd-file, so I created a shell script and set it in there. The launchd-file starts the shell script.
~/Library/LaunchAgents/frontail.openhab.logs.plist:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs>
<plist version="1.0">
<dict>
<key>Label</key>
<string>frontail.openhab.logs</string>
<key>ProgramArguments</key>
<array>
<string>/Users/buzink/frontail.sh</string>
<!-- <string>/usr/local/bin/frontail</string>
<string>/usr/local/lib/node_modules/frontail/bin/frontail</string>>
<string>-d</string>
<string>--pid-path /tmp/frontail.pid</string>
<string>/Users/buzink/openhab/userdata/logs/*.log</string>-->
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<false/>
<key>StandardErrorPath</key>
<string>/tmp/frontail.openhab.logs.err</string>
<key>StandardOutPath</key>
<string>/tmp/frontail.openhab.logs.out</string>
<key>WorkingDirectory</key>
<string>/usr/local/lib/node_modules/frontail/</string>
</dict>
</plist>
~/frontail.sh:
#!/bin/bash
export PATH="$PATH:"/usr/local/bin/
/usr/local/bin/frontail -d --pid-path /tmp/frontail.pid /Users/buzink/openhab/userdata/logs/*.log