run.sh: integrate handling for tirex daemon
Implements issue67
This commit is contained in:
parent
b846ab99c2
commit
e225e9973f
58
run.sh
58
run.sh
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
set -x
|
set -x
|
||||||
|
|
||||||
|
STOP_CONT="no"
|
||||||
|
|
||||||
function createPostgresConfig() {
|
function createPostgresConfig() {
|
||||||
cp /etc/postgresql/10/main/postgresql.custom.conf.tmpl /etc/postgresql/10/main/postgresql.custom.conf
|
cp /etc/postgresql/10/main/postgresql.custom.conf.tmpl /etc/postgresql/10/main/postgresql.custom.conf
|
||||||
sudo -u postgres echo "autovacuum = $AUTOVACUUM" >> /etc/postgresql/10/main/postgresql.custom.conf
|
sudo -u postgres echo "autovacuum = $AUTOVACUUM" >> /etc/postgresql/10/main/postgresql.custom.conf
|
||||||
@ -12,6 +14,39 @@ function setPostgresPassword() {
|
|||||||
sudo -u postgres psql -c "ALTER USER renderer PASSWORD '${PGPASSWORD:-renderer}'"
|
sudo -u postgres psql -c "ALTER USER renderer PASSWORD '${PGPASSWORD:-renderer}'"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# handler for term signal
|
||||||
|
function sighandler_TERM() {
|
||||||
|
echo "signal SIGTERM received\n"
|
||||||
|
|
||||||
|
echo "terminate apache2"
|
||||||
|
service apache2 stop
|
||||||
|
|
||||||
|
PID=`ps -eaf | grep renderd | grep -v grep | awk '{print $2}'`
|
||||||
|
if [[ "" != "$PID" ]]; then
|
||||||
|
echo "send SIGTERM to renderd PID=$PID"
|
||||||
|
kill -n 15 $PID
|
||||||
|
fi
|
||||||
|
|
||||||
|
PID=`ps -eaf | grep tirex-master | grep -v grep | awk '{print $2}'`
|
||||||
|
if [[ "" != "$PID" ]]; then
|
||||||
|
echo "send SIGTERM to tirex-master PID=$PID"
|
||||||
|
kill -n 15 $PID
|
||||||
|
fi
|
||||||
|
|
||||||
|
PID=`ps -eaf | grep tirex-backend-manager | grep -v grep | awk '{print $2}'`
|
||||||
|
if [[ "" != "$PID" ]]; then
|
||||||
|
echo "send SIGTERM to tirex-backend-manager PID=$PID"
|
||||||
|
kill -n 15 $PID
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "terminate postgresql"
|
||||||
|
service postgresql stop
|
||||||
|
|
||||||
|
STOP_CONT="yes"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if [ "$#" -ne 1 ]; then
|
if [ "$#" -ne 1 ]; then
|
||||||
echo "usage: <import|run>"
|
echo "usage: <import|run>"
|
||||||
echo "commands:"
|
echo "commands:"
|
||||||
@ -20,6 +55,7 @@ if [ "$#" -ne 1 ]; then
|
|||||||
echo "environment variables:"
|
echo "environment variables:"
|
||||||
echo " THREADS: defines number of threads used for importing / tile rendering"
|
echo " THREADS: defines number of threads used for importing / tile rendering"
|
||||||
echo " UPDATES: consecutive updates (enabled/disabled)"
|
echo " UPDATES: consecutive updates (enabled/disabled)"
|
||||||
|
echo " RENDERERAPP: select render application renderd (default) or tirex"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -67,6 +103,9 @@ if [ "$1" = "import" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$1" = "run" ]; then
|
if [ "$1" = "run" ]; then
|
||||||
|
# add handler for signal SIHTERM
|
||||||
|
trap 'sighandler_TERM' 15
|
||||||
|
|
||||||
# Clean /tmp
|
# Clean /tmp
|
||||||
rm -rf /tmp/*
|
rm -rf /tmp/*
|
||||||
|
|
||||||
@ -92,9 +131,22 @@ if [ "$1" = "run" ]; then
|
|||||||
/etc/init.d/cron start
|
/etc/init.d/cron start
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Run
|
if [ "$RENDERERAPP" = "renderd" ]; then
|
||||||
sudo -u renderer renderd -f -c /usr/local/etc/renderd.conf
|
# start renderd
|
||||||
service postgresql stop
|
sudo -u renderer renderd -f -c /usr/local/etc/renderd.conf &
|
||||||
|
|
||||||
|
elif [ "$RENDERERAPP" = "tirex" ]; then
|
||||||
|
# start tirex
|
||||||
|
sudo -u renderer tirex-backend-manager -f &
|
||||||
|
sudo -u renderer tirex-master -d -f &
|
||||||
|
else
|
||||||
|
echo "RENDERERAPP not valid use renderd or tirex"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "wait for terminate signal"
|
||||||
|
while [ "$STOP_CONT" = "no" ] ; do
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user