forked from spujadas/elk-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
start.sh
53 lines (39 loc) · 1.33 KB
/
start.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/bash
#
# /usr/local/bin/start.sh
# Start Elasticsearch, Logstash and Kibana services
#
# spujadas 2015-10-09; added initial pidfile removal and graceful termination
# WARNING - This script assumes that the ELK services are not running, and is
# only expected to be run once, when the container is started.
# Do not attempt to run this script if the ELK services are running (or be
# prepared to reap zombie processes).
## handle termination gracefully
_term() {
echo "Terminating ELK"
service elasticsearch stop
service logstash stop
service kibana stop
exit 0
}
trap _term SIGTERM
## remove pidfiles in case previous graceful termination failed
# NOTE - This is the reason for the WARNING at the top - it's a bit hackish,
# but if it's good enough for Fedora (https://goo.gl/88eyXJ), it's good
# enough for me :)
rm -f /var/run/elasticsearch/elasticsearch.pid /var/run/logstash.pid \
/var/run/kibana4.pid
## start services
service elasticsearch start
service logstash start
# wait for elasticsearch to start up
# - https://github.com/elasticsearch/kibana/issues/3077
counter=0
while [ ! "$(curl localhost:9200 2> /dev/null)" -a $counter -lt 30 ]; do
sleep 1
((counter++))
echo "waiting for Elasticsearch to be up ($counter/30)"
done
service kibana start
tail -f /var/log/elasticsearch/elasticsearch.log &
wait