title: Running logstash with monit
body: <p>I am trying to start logstash with monit. 
  I have a directory where i have logstash in which /home/slee/PROJECT/logstash.</p>
  
  <p>First I create a bash script(wrapper) to run logstash in as suggested in the monit site. 
  I created this:</p>
  
  <pre><code>#!/bin/bash
  export JAVA_HOME=/usr/local/java/
  #CLASSPATH=/root/lo2/logstash/logstash-1.1.0-monolithic.jar
  #CONFIG=/root/lo2/logstash/stag_conf.conf
  CLASSPATH=/home/slee/PROJECT/logstash/logstash-1.1.0-monolithic.jar
  CONFIG=/home/slee/PROJECT/logstash/local.conf
  
  case $1 in
  start)
      echo $$ &gt; /var/run/logstash.pid;
      #exec 2&gt;&amp;1 java -jar $CLASSPATH agent -f $CONFIG -- web --backend elasticsearch:///?local 1&gt; /var/log/apache2/logstash.log
      exec java -jar $CLASSPATH agent -f $CONFIG --log /var/log/logstash-indexer.out -- web --log /var/log/logstash-web.out --backend elasticsearch://localhost/
      ;;
  stop)
      kill `cat /var/run/logstash.pid` ;;
  *)
  echo "usage: logstash {start|stop}" ;;
  esac
  exit 0
  </code></pre>
  
  <p>If I run this with ./logstash start. It works like a charm but if I add it to monit as such:</p>
  
  <pre><code>check process logstash with pidfile /var/run/logstash.pid
  group system
  start program = "/bin/bash /home/slee/PROJECT/twyxt/logstash/logstash.sh"
  stop  program = "/bin/bash /home/slee/PROJECT/twyxt/logstash/logstash.sh"
  if failed host localhost port 9292
  protocol http then restart
  if 5 restarts within 5 cycles then timeout
  </code></pre>
  
  <p>It does not start logstash at all. Can anyone tell me why? Or give me an Idea on how to solve this.</p>
  
  <p>I sent an email to the logstash group and they gave me this link <a href="http://cookbook.logstash.net/recipes/using-upstart/#upstart%20logstash%20config" rel="nofollow">http://cookbook.logstash.net/recipes/using-upstart/#upstart%20logstash%20config</a></p>
  
  <p>I tried it but I kept getting a 
      slee@ubuntu:~/PROJECT/logstash/upstart/backup$ sudo initctl start logstash
      initctl: Unknown job: logstash</p>
  
  <p>I dont know what could be wrong with the logstash config since I changed the directory to my own. Please help.</p>
  
  <p>Best Regards,
  Stevenson Lee</p>