#!/bin/sh
# Run logstash from source
#
# This is most useful when done from a git checkout.
#
# Usage:
#     bin/logstash <command> [arguments]
#
# See 'bin/logstash help' for a list of commands.
#
# NOTE: One extra command is available 'deps'
# The 'deps' command will install dependencies for logstash.
#
# If you do not have ruby installed, you can set "USE_JRUBY=1"
# in your environment and this script will download and use
# a release of JRuby for you.

# Defaults you can override with environment variables
LS_HEAP_SIZE="${LS_HEAP_SIZE:=500m}"

unset CDPATH
basedir=$(cd `dirname $0`/..; pwd)
. "${basedir}/bin/logstash.lib.sh"

setup

# Export these so that they can be picked up by file input (and others?).
export HOME SINCEDB_DIR

case $1 in
  deps) install_deps ;;
  env) env "$@" ;;
  -*)
    if [ -z "$VENDORED_JRUBY" ] ; then
      exec "${RUBYCMD}" "-I${RUBYLIB}" "${basedir}/lib/logstash/runner.rb" "agent" "$@"
    else
      exec "${JAVACMD}" $JAVA_OPTS "-jar" "$JRUBY_JAR" "-I${RUBYLIB}" "${basedir}/lib/logstash/runner.rb" "agent" "$@"
    fi
    ;;
  *)
    if [ -z "$VENDORED_JRUBY" ] ; then
      exec "${RUBYCMD}" "-I${RUBYLIB}" "${basedir}/lib/logstash/runner.rb" "$@"
    else
      exec "${JAVACMD}" $JAVA_OPTS "-jar" "$JRUBY_JAR" "-I${RUBYLIB}" "${basedir}/lib/logstash/runner.rb" "$@"
    fi
    ;;
esac


