每当系统启动时,我都需要在MAC OS X系统上作为守护进程运行logstash代理
终端: / usr / local / logstash / bin / logstash agent -f /usr/local/etc/cvlog.conf
每个终端程序正在成功运行,但作为守护程序,它无法启动。
我的com.bcd.logstash.plist
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.bcd.logstash</string>
<key>KeepAlive</key>
<dict>
<key>SuccessfulExit</key>
<false />
</dict>
<key>ProgramArguments</key>
<array>
<string>/usr/local/logstash/bin/logstash</string>
<string>agent</string>
<string>-f</string>
<string>/usr/local/etc/cvlog.conf</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
我从:
开始launchtl load /Library/LaunchDaemons/com.bcd.logstash.plist
Syslog错误消息
com.apple.launchd [1](com.bcd.logstash [pid]):退出代码:1
com.apple.launchd [1](com.bcd.logstash [pid]):退出代码:143
我的plist有什么问题?
答案 0 :(得分:0)
简短版:
在启动时从launchd运行时,没有$ HOME环境变量。因此sincedb_path位置的默认值无效。您可以通过向logstash配置中的每个输入文件添加sincedb_path => "/usr/local/logstash/.sincedb"
等行来指定它。
长版:
我遇到了同样的问题。我通过将这些行添加到plist来监视logstash的输出:
<key>StandardErrorPath</key>
<string>/Library/Logs/LittleSnitchDaemon.log</string>
<key>StandardOutPath</key>
<string>/Library/Logs/LittleSnitchDaemon.log</string>
我发现错误:"No SINCEDB_DIR or HOME environment variable set, I don't know where to keep track of the files I'm watching. Either set HOME or SINCEDB_DIR in your environment, or set sincedb_path in in your Logstash config for the file input with path '[\"/var/log/apache2/access_log\"]'"
最终我找到了https://logstash.jira.com/browse/LOGSTASH-1967。它似乎描述了同样的问题。我通过将参数sincedb_path => "/usr/local/logstash/.sincedb"
添加到我正在阅读的每个日志文件中来解决它。