3 # elasticsearch<%= @name %> <summary>
5 # chkconfig: 2345 80 20
6 # description: Starts and stops a single elasticsearch instance on this system
10 # Provides: Elasticsearch-<%= @name %>
11 # Required-Start: $network $named
12 # Required-Stop: $network $named
13 # Default-Start: 2 3 4 5
15 # Short-Description: This service manages the elasticsearch daemon
16 # Description: Elasticsearch is a very scalable, schema-free and high-performance search solution supporting multi-tenancy and near realtime search.
20 # init.d / servicectl compatibility (openSUSE)
22 if [ -f /etc/rc.status ]; then
28 # Source function library.
30 if [ -f /etc/rc.d/init.d/functions ]; then
31 . /etc/rc.d/init.d/functions
34 exec="/usr/share/elasticsearch/bin/elasticsearch"
35 prog="elasticsearch-<%= @name %>"
36 pidfile=/var/run/elasticsearch/${prog}.pid
38 [ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
41 export ES_HEAP_NEWSIZE
46 lockfile=/var/lock/subsys/$prog
48 # backwards compatibility for old config sysconfig files, pre 0.90.1
49 if [ -n $USER ] && [ -z $ES_USER ] ; then
54 if [ -x "$JAVA_HOME/bin/java" ]; then
55 JAVA="$JAVA_HOME/bin/java"
60 if [ ! -x "$JAVA" ]; then
61 echo "Could not find any executable java binary. Please install java in your PATH or set JAVA_HOME"
68 [ -x $exec ] || exit 5
69 [ -f $CONF_FILE ] || exit 6
70 if [ -n "$MAX_LOCKED_MEMORY" -a -z "$ES_HEAP_SIZE" ]; then
71 echo "MAX_LOCKED_MEMORY is set - ES_HEAP_SIZE must also be set"
74 if [ -n "$MAX_OPEN_FILES" ]; then
75 ulimit -n $MAX_OPEN_FILES
77 if [ -n "$MAX_LOCKED_MEMORY" ]; then
78 ulimit -l $MAX_LOCKED_MEMORY
80 if [ -n "$MAX_MAP_COUNT" ]; then
81 sysctl -q -w vm.max_map_count=$MAX_MAP_COUNT
83 if [ -n "$WORK_DIR" ]; then
85 chown "$ES_USER":"$ES_GROUP" "$WORK_DIR"
87 echo -n $"Starting $prog: "
88 # if not running, start it up here, usually something like "daemon $exec"
89 daemon --user $ES_USER --pidfile $pidfile $exec -p $pidfile -d -Des.default.path.home=$ES_HOME -Des.default.path.logs=$LOG_DIR -Des.default.path.data=$DATA_DIR -Des.default.path.work=$WORK_DIR -Des.default.path.conf=$CONF_DIR
92 [ $retval -eq 0 ] && touch $lockfile
97 echo -n $"Stopping $prog: "
98 # stop it here, often "killproc $prog"
99 killproc -p $pidfile -d 20 $prog
102 [ $retval -eq 0 ] && rm -f $lockfile
120 # run checks to determine if the service is running or use generic status
121 status -p $pidfile $prog
125 rh_status >/dev/null 2>&1
131 rh_status_q && exit 0
135 rh_status_q || exit 0
142 rh_status_q || exit 7
151 condrestart|try-restart)
152 rh_status_q || exit 0
156 echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"