Skip to content

Commit e444817

Browse files
committed
wait properly
1 parent 1867c2f commit e444817

3 files changed

Lines changed: 54 additions & 25 deletions

File tree

irods/test/harness/003_compile-specific-python.Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@ RUN make install
1313
WORKDIR /
1414
RUN /root/python/bin/python3 -m pip install virtualenv
1515
RUN chmod a+rx /root
16+
COPY manage_irods5_procs /
1617
ENV PYTHON_VERSION=${python_version}

irods/test/harness/manage_irods5_procs

Lines changed: 46 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,54 @@ else
44
LAUNCH='sudo su - irods -c'
55
fi
66

7+
STDOUT=""
8+
PID=""
9+
710
start() {
8-
$LAUNCH 'irodsServer -d -p /tmp/irods.pid'
11+
if [ -z "$STDOUT" ] ; then
12+
$LAUNCH 'irodsServer -d -p /tmp/irods.pid'
13+
else
14+
$LAUNCH 'irodsServer --stdout -p /tmp/irods.pid >/tmp/irods.log &'
15+
fi
916
}
1017

11-
stop() {
12-
$LAUNCH 'kill -QUIT $(cat /tmp/irods.pid) ; rm -f /tmp/irods.pid >/dev/null 2>&1'
18+
rm_pid_file() {
19+
if [ -z "$PID" ]; then
20+
PID=$($LAUNCH 'cat /tmp/irods.pid')
21+
fi
22+
$LAUNCH 'rm -f /tmp/irods.pid >/dev/null 2>&1'
1323
}
1424

15-
if [ "$1" = "start" ]; then
16-
start
17-
elif [ "$1" = "start-bg" ]; then
18-
$LAUNCH 'irodsServer --stdout -p /tmp/irods.pid >/tmp/irods.log &'
19-
elif [ "$1" = "rescan-config" ]; then
20-
$LAUNCH 'pkill -HUP irodsServer'
21-
elif [ "$1" = "status" ]; then
22-
pgrep -afl "irods(Delay|Agent|Server)"
23-
elif [ "$1" = "stop" ]; then
24-
stop
25-
elif [ "$1" = "restart" ]; then
26-
stop && start
27-
elif [ "$1" = "wait" ]; then
28-
$LAUNCH '
29-
pid=`cat /tmp/irods.pid 2>/dev/null`;
30-
[ -n "$pid" ] && { while ps -eo pid |grep $pid >/dev/null 2>&1; do sleep 1; done; }'
31-
else
32-
echo >&2 "usage: $0 [start|status|stop]"
33-
exit 2
34-
fi
25+
stop() {
26+
$LAUNCH 'kill -QUIT $(cat /tmp/irods.pid)'
27+
rm_pid_file
28+
}
29+
30+
wait() {
31+
$LAUNCH "
32+
[ -z '$PID' ] && { echo >&2 'nothing to wait for.' ; exit 2; }
33+
while ps -eo pid |grep $PID >/dev/null 2>&1; do sleep 1; done;"
34+
}
35+
36+
# -----------------------------------
37+
while [ -n "$1" ]; do
38+
if [ "$1" = "stdout" ]; then
39+
STDOUT=1
40+
elif [ "$1" = "start" ]; then
41+
start
42+
elif [ "$1" = "rescan-config" ]; then
43+
$LAUNCH 'pkill -HUP irodsServer'
44+
elif [ "$1" = "status" ]; then
45+
pgrep -afl "irods(Delay|Agent|Server)"
46+
elif [ "$1" = "stop" ]; then
47+
stop
48+
elif [ "$1" = "restart" ]; then
49+
stop && start
50+
elif [ "$1" = "wait" ]; then
51+
wait
52+
else
53+
echo >&2 "usage: $0 [start|status|stop]"
54+
exit 2
55+
fi
56+
shift
57+
done

irods/test/harness/setup_python_rule_engine

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ DIR=$(dirname "$0")
1212

1313
server_ctl() {
1414
if "$DIR"/irods_version_greater_or_equal_to --use_env_var=IRODS_PACKAGE_VERSION 5.0; then
15-
/manage_irods5_procs $1
15+
W=""
16+
if [ "$1" = stop ]; then
17+
W=wait
18+
fi
19+
/manage_irods5_procs $1 $W
1620
else
1721
~/irodsctl $1
1822
fi
@@ -72,8 +76,9 @@ server_ctl start
7276

7377
if [ -n "$wait" ]; then
7478
times=0
79+
OUTFILE=/tmp/irule_output.stderr
7580
while :; do
76-
irule -a | grep "irods_rule_engine_plugin-python-instance" >/dev/null 2>&1
81+
irule -a 2>/dev/null| grep irods_rule_engine_plugin-python-instance >/dev/null
7782
[ ${PIPESTATUS[1]} -eq 0 ] && break
7883
sleep 1
7984
if [ $((++times)) -ge 10 ]; then

0 commit comments

Comments
 (0)