-
Notifications
You must be signed in to change notification settings - Fork 13
/
run.sh
executable file
·88 lines (68 loc) · 1.33 KB
/
run.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/bin/bash
# redirect set -x (stderr by default) to stdout
set -x
exec 2>&1
# abort on error
set -e
EXTRA=""
if [ -z "$DB_NAME" ]; then
DB_NAME="eost"
fi
if [ -z "$RECOVER" ]; then
EXTRA=$EXTRA
else
EXTRA="$EXTRA --recover"
fi
if [ -z "$FLUSHTIME" ]; then
EXTRA=$EXTRA
else
EXTRA="$EXTRA --flushtime $FLUSHTIME"
fi
if [ -z "$DROPDB" ]; then
EXTRA=$EXTRA
else
EXTRA="$EXTRA --dropdb"
fi
if [ -z "$KEEP" ]; then
KEEP="2"
fi
if [ -z $SEEDLINK_SERVER ]; then
echo "please set SEEDLINK_SERVER env"
echo "using -e SEEDLINK_SERVER=10.0.0.1"
exit 1
fi
if [ -z $SEEDLINK_PORT ]; then
SEEDLINK_PORT=18000
fi
if [ -z $FDSN_WS_STATION_SERVER ]; then
FDSN_WS_STATION_SERVER="RESIF"
fi
pid=0
# SIGTERM-handler
term_handler() {
if [ $pid -ne 0 ]; then
kill -SIGTERM "$pid"
wait "$pid"
fi
exit 143; # 128 + 15 -- SIGTERM
}
# setup handlers
trap 'kill ${!}; term_handler' SIGTERM
# run application
cd /data
seedlink2influxdb \
--dbserver $INFLUXDB_PORT_8086_TCP_ADDR \
--dbport $INFLUXDB_PORT_8086_TCP_PORT \
--slserver $SEEDLINK_SERVER \
--slport $SEEDLINK_PORT \
--fdsnserver $FDSN_WS_STATION_SERVER \
--streams $SEEDLINK_STREAMS \
--db $DB_NAME \
--keep $KEEP \
$EXTRA 2>&1 &
pid="$!"
# wait indefinetely
while true
do
tail -f /dev/null & wait ${!}
done