Starte Gollum med launchd

Vegard Øye

OS X startes Gollum automatisk med launchd. Opprett en fil ~/Library/LaunchAgents/com.personalwiki.gollum.plist (med eksklusive rettigheter, dvs. chmod 600) som inneholder dette:

<?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.user.gollum</string>
  <key>ProgramArguments</key>
  <array>
    <string>/usr/bin/gollum</string>
    <string>/Users/vegard/Documents/wiki</string>
  </array>
  <key>RunAtLoad</key>
  <true/>
</dict>
</plist>

Oppdatering 2016-07-29: Å få http-server til å starte automatisk krever at man eksplisitt oppgir plasseringen til node, for launchd leser ikke /usr/local/bin. Serveren startes med Bash-skriptet start_httpserver.sh:

#!/bin/bash
NODE="/usr/local/bin/node"
PROGRAM="/usr/local/bin/http-server"
HTTPSERVER="$NODE $PROGRAM"
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd "$DIR"
$HTTPSERVER . -p 8000

Skriptet refereres så av ~/Library/LaunchAgents/com.personalwiki.httpserver.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.user.httpserver</string>
  <key>ProgramArguments</key>
  <array>
    <string>/Users/vegard/Documents/wiki/start_httpserver.sh</string>
  </array>
  <key>RunAtLoad</key>
  <true/>
  <key>StandardErrorPath</key>
  <string>/tmp/mycommand.err</string>
  <key>StandardOutPath</key>
  <string>/tmp/mycommand.out</string>
</dict>
</plist>

For å kunne debugge launchd dersom noe skulle gå galt, loggføres resultatet til StandardErrorPath og StandardOutPath.