2

我想在 OSX Mavericks 上为我的 Gitblit 创建一个 LaunchDaemon,这是我的文件(org.gitblit.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>KeepAlive</key>
    <true/>
    <key>Label</key>
    <string>org.gitblit.plist</string>
    <key>ProgramArguments</key>
    <array>
      <string>/usr/bin/java</string>
      <string>--baseFolder</string>
      <string>data</string>
      <string>-jar</string>
      <string>/Applications/gitblit/gitblit.jar</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
  </dict>
</plist>

它不起作用,但是当我尝试java -jar gitblit.jar --baseFolder data/Applications/gitblit 时,一切正常。我错过了什么吗?

4

2 回答 2

0

Gitblit GO 发行版附带了一个gitblit.sh可以用于此目的的 shell 脚本。~/Library/LaunchAgents/org.gitblit.plist这是我使用的 LaunchAgent plist 的版本。

请注意添加的WorkingDirectory密钥以及日志文件以防出错。

<?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>KeepAlive</key>
    <true/>
    <key>Label</key>
    <string>org.gitblit.plist</string>
    <key>ProgramArguments</key>
    <array>
      <string>/bin/bash</string>
      <string>/Applications/gitblit/gitblit.sh</string>
    </array>
    <key>WorkingDirectory</key>
    <string>/Applications/gitblit/</string>
    <key>RunAtLoad</key>
    <true/>
    <key>StandardOutPath</key>
    <string>/Applications/gitblit/stdout.txt</string>
    <key>StandardErrorPath</key>
    <string>/Applications/gitblit/sterr.txt</string>
  </dict>
</plist>
于 2014-07-21T06:08:59.453 回答
0

所以我最终以这样的方式作弊:

我将此脚本保存在/opt/scripts/start_gitblit.sh

#!/bin/bash
cd /Applications/gitblit/
java -jar gitblit.jar --baseFolder data 

然后我将此属性列表存储在~/Library/LaunchAgents/org.gitblit.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>KeepAlive</key>
    <true/>
    <key>Label</key>
    <string>org.gitblit.plist</string>
    <key>ProgramArguments</key>
    <array>
      <string>/bin/bash</string>
      <string>/opt/scripts/start_gitblit.sh</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
  </dict>
</plist>

现在一切正常。

于 2013-11-10T06:08:58.627 回答