forked from Aquaveo/ngiab-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.sh
62 lines (46 loc) · 1.34 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
#!/bin/bash
tail_file() {
echo "tailing file $1"
ALIGN=27
LENGTH=`echo $1 | wc -c`
PADDING=`expr ${ALIGN} - ${LENGTH}`
PREFIX=$1`perl -e "print ' ' x $PADDING;"`
file="/var/log/$1"
# each tail runs in the background but prints to stdout
# sed outputs each line from tail prepended with the filename+padding
tail -qF $file | sed --unbuffered "s|^|${PREFIX}:|g" &
}
echo_status() {
local args="${@}"
tput setaf 4
tput bold
echo -e "- $args"
tput sgr0
}
echo_status "Starting up..."
echo_status "Enforcing start state... (This might take a bit)"
salt-call --local state.apply
echo_status "Fixing permissions"
chown -R www: /usr/lib/tethys
chown -R www: /var/lib/tethys_persist
chown -R www: /var/log/tethys
chmod -R 777 /var/lib/nginx
echo_status "Starting supervisor"
# Start Supervisor
/usr/bin/supervisord
echo_status "Done!"
# Watch Logs
echo_status "Watching logs. You can ignore errors from either apache (httpd) or nginx depending on which one you are using."
log_files=("httpd/access_log"
"httpd/error_log"
"nginx/access.log"
"nginx/error.log"
"supervisor/supervisord.log"
"tethys/tethys.log")
# When this exits, exit all background tail processes
trap 'kill $(jobs -p)' EXIT
for log_file in "${log_files[@]}"; do
tail_file "${log_file}"
done
# Read output from tail; wait for kill or stop command (docker waits here)
wait