-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathXDMoD-start
79 lines (70 loc) · 2.34 KB
/
XDMoD-start
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
#!/bin/bash
#
# Entry point for the XDMoD container.
#
ingest_log() {
local ts="$(date '+%Y-%m-%d %H:%M:%S%z')"
printf "[${ts}] %s\n" "$@" >> /var/log/xdmod/ingest-queue.log
}
# Dump any /var/run state that's left hanging around:
rm -rf /var/run/httpd/* /var/run/mariadb/*
# Ensure there's a PHP date.timezone configured:
grep '^date\.timezone =' /etc/php.ini >/dev/null 2>/dev/null
if [ $? -ne 0 -a ! -f /etc/php.d/date.ini ]; then
cat <<EOT > /etc/php.d/date.ini
;
; Default timezone
;
date.timezone = America/New_York
EOT
fi
# Start Apache:
httpd -k start
# Start MySQL:
if [ ! -e /var/lib/mysql/mysql/user.frm ]; then
mkdir /var/lib/mysql
chown mysql:mysql /var/lib/mysql
chmod 0755 /var/lib/mysql
/usr/bin/mysql_install_db --rpm --datadir="/var/lib/mysql" --user="mysql"
fi
sudo --user mysql --group mysql /usr/bin/mysqld_safe --basedir=/usr &
# Ensure the ingest queue directories are okay:
for subdir in in out error; do
if [ ! -e /var/lib/XDMoD-ingest-queue/${subdir} ]; then
mkdir --parents --mode=0755 /var/lib/XDMoD-ingest-queue/${subdir}
fi
done
# Set variables for xdmod-shredder
if [ -z "$CLUSTER_NAME" ]; then
CLUSTER_NAME="darwin"
fi
if [ -z "$RESOURCE_LOG_FORMAT" ]; then
RESOURCE_FORMAT="slurm"
fi
# Enter our infinite runloop:
while true; do
if [ -e /var/lib/XDMoD-ingest-queue/enable ]; then
out_count=0
for infile in /var/lib/XDMoD-ingest-queue/in/*; do
if [ -f "$infile" ]; then
ingest_output="$(xdmod-shredder -r $CLUSTER_NAME -f $RESOURCE_LOG_FORMAT -i "$infile" 2>&1)"
if [ $? -ne 0 ]; then
mv "$infile" /var/lib/XDMoD-ingest-queue/error
ingest_log "unable to process $infile" "$ingest_output"
else
mv "$infile" /var/lib/XDMoD-ingest-queue/out
ingest_log "successfully processed $infile"
out_count=$((out_count+1))
fi
fi
done
if [ $out_count -gt 0 ]; then
logfile="xdmod-ingestor-$(date +%Y%m%dT%H%M%S).log"
xdmod-ingestor > /var/lib/XDMoD-ingest-queue/out/${logfile} 2>&1
if [ $? -ne 0 ]; then
ingest_log "failure running xdmod-ingestor, see ${logfile}"
fi
fi
fi
sleep ${XDMOD_INGEST_PERIOD:-300}
done