forked from pjbriggs/galaxy-admin-utils
-
Notifications
You must be signed in to change notification settings - Fork 0
/
galaxy_status.sh
executable file
·78 lines (78 loc) · 1.87 KB
/
galaxy_status.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
#!/bin/sh
#
# galaxy_status.sh: monitor status of Galaxy server processes
# Peter Briggs, University of Manchester 2013
#
# Usage: galaxy_status.sh
#
# Must be executed from the directory where the .pid and .log
# files for the Galaxy server processes are being written
#
# Use "watch galaxy_status.sh" to monitor Galaxy
#
# Announce location
cwd=`pwd`
echo "Status of galaxy running from $cwd"
echo
#
# Initialise flag variables
servers=
all_active=yes
galaxy_error_state=
#
# Collect PID files for server processes
pid_files=`ls *.pid 2>/dev/null`
#
# Check status of each process
# - PID must be active (indicates server process is running)
# - log file must announce that server is listening (indicates
# server process is active)
#
for f in $pid_files ; do
server=${f%%.*}
servers="$servers $server"
pid=`cat $f 2>/dev/null`
if [ -z "$pid" ] ; then
pid="?"
fi
status=`ps --pid $pid --noheaders 2>/dev/null`
if [ ! -z "$status" ] ; then
status=Running
is_active=
if [ -f $server.log ] ; then
serving=`grep "^Starting server in PID $pid" $server.log -A 1 | grep "^serving on"`
if [ ! -z "$serving" ] ; then
port=`echo $serving | cut -d: -f3`
is_active=yes
status="Active (port $port)"
fi
fi
if [ -z "$is_active" ] ; then
# At least one server is inactive
all_active=
fi
else
status="Not running"
galaxy_error_state=yes
all_active=
fi
echo Server $server$'\t'PID $pid$'\t'Status $status
done
#
# Summarise status of Galaxy based on status of individual
# server processes
echo
if [ -z "$servers" ] ; then
echo No servers running
elif [ -z "$galaxy_error_state" ] ; then
echo -n "All servers running"
if [ "$all_active" == "yes" ] ; then
echo " and active"
else
echo
fi
else
echo One or more servers in error state
fi
##
#