logstash的upstart脚本,编写处理fork的pid文件

时间:2013-07-21 21:33:30

标签: upstart monit logstash

我正在使用example upstart script for logstash,但在编写monit的pid文件时无法在/var/run/logstash.pid中使用

当我使用“echo $$> /var/run/logstash.pid”时,它会将错误的pid值写入文件,我认为它通常是fork之前的值。有解决方案吗?

# logstash - agent instance
#

description     "logstash agent instance"

start on virtual-filesystems
stop on runlevel [06]

# Respawn it if the process exits
respawn
respawn limit 5 30
limit nofile 65550 65550
expect fork

# You need to chdir somewhere writable because logstash needs to unpack a few
# temporary files on startup.
chdir /home/logstash

script
  # This runs logstash agent as the 'logstash' user
  echo $$ > /var/run/logstash.pid
  su -s /bin/sh -c 'exec "$0" "$@"' logstash -- /usr/bin/java -jar logstash.jar agent -f /etc/logstash/agent.conf --log /var/log/logstash.log &
  emit logstash-agent-running
end script

0 个答案:

没有答案