Skip to content
This repository was archived by the owner on Oct 3, 2023. It is now read-only.

Commit 26063e0

Browse files
committed
Automatic health check and restart if some spawned iip processes are exited
1 parent 17ac198 commit 26063e0

File tree

5 files changed

+38
-12
lines changed

5 files changed

+38
-12
lines changed

configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Process this file with autoconf to produce a configure script.
22

3-
AC_INIT(iipsrv,1.3.2)
3+
AC_INIT(iipsrv,1.4.0)
44
AC_CONFIG_MACRO_DIR([m4])
55
AM_INIT_AUTOMAKE
66

docker/Dockerfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ FROM ${FROM_NAMESPACE}/base:$FROM_VERSION
2020

2121
RUN apt-get -y update && \
2222
apt-get install -y \
23+
cron \
2324
git \
2425
libjpeg8-dev \
2526
libmemcached-dev \
@@ -30,6 +31,7 @@ RUN apt-get -y update && \
3031
psmisc \
3132
autoconf \
3233
libtool \
34+
rsyslog \
3335
spawn-fcgi \
3436
software-properties-common && \
3537
apt-get -y build-dep openslide && \
@@ -71,6 +73,12 @@ RUN cd /opt/iipsrv && \
7173
COPY deploy.sh /tmp/deploy.sh
7274
RUN chmod +x /tmp/deploy.sh
7375

76+
COPY start-iip.sh /tmp/start-iip.sh
77+
RUN chmod +x /tmp/start-iip.sh
78+
79+
COPY check-status.sh /tmp/check-status.sh
80+
RUN chmod +x /tmp/check-status.sh
81+
7482
RUN ldconfig -v
7583

7684
ENTRYPOINT ["/tmp/deploy.sh"]

docker/check-status.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
. /tmp/iip-configuration.sh
2+
3+
COUNT=$(ps aux | grep /opt/iipsrv/src/iipsrv.fcgi | grep -v grep | wc -l)
4+
if [ $COUNT -lt $NB_IIP_PROCESS ]; then
5+
echo "$COUNT / $NB_IIP_PROCESS on $(date)"
6+
killall -9 /opt/iipsrv/src/iipsrv.fcgi
7+
/tmp/start-iip.sh
8+
fi;

docker/deploy.sh

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,9 @@ echo " create 640 root root" >> /etc/logrotate.d/iip
2626
echo " su root root" >> /etc/logrotate.d/iip
2727
echo "}" >> /etc/logrotate.d/iip
2828

29-
# IIP configuration options
30-
export VERBOSITY=10
31-
export LOGFILE=/tmp/iip.out
3229
. /tmp/iip-configuration.sh
3330
sysctl -w net.core.somaxconn=2048
3431

35-
env
3632

3733
# Configure Nginx
3834
PORT=9000
@@ -46,12 +42,15 @@ mv /tmp/nginx.conf.sample /usr/local/nginx/conf/nginx.conf
4642
echo "start nginx"
4743
/usr/local/nginx/sbin/nginx &
4844

49-
# Spawn FCGI processes
50-
COUNTER=0
51-
while [ $COUNTER -lt $NB_IIP_PROCESS ]; do
52-
echo "spawn process"
53-
spawn-fcgi -f /opt/iipsrv/src/iipsrv.fcgi -a 127.0.0.1 -p $(($PORT+$COUNTER))
54-
let COUNTER=COUNTER+1
55-
done
45+
/tmp/start-iip.sh
46+
47+
touch /tmp/crontab
48+
echo "NB_IIP_PROCESS=$NB_IIP_PROCESS" >> /tmp/crontab
49+
echo "*/1 * * * * /bin/bash /tmp/check-status.sh >> /tmp/cron.out" >> /tmp/crontab
50+
crontab /tmp/crontab
51+
rm /tmp/crontab
52+
53+
service rsyslog restart
54+
service cron restart
5655

5756
tail -F /tmp/iip.out

docker/start-iip.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
export VERBOSITY=10
2+
export LOGFILE=/tmp/iip.out
3+
. /tmp/iip-configuration.sh
4+
5+
PORT=9000
6+
COUNTER=0
7+
while [ $COUNTER -lt $NB_IIP_PROCESS ]; do
8+
echo "spawn process"
9+
spawn-fcgi -f /opt/iipsrv/src/iipsrv.fcgi -a 127.0.0.1 -p $(($PORT+$COUNTER))
10+
let COUNTER=COUNTER+1
11+
done

0 commit comments

Comments
 (0)