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
|
||||
|
||||
STOP_CONT="no"
|
||||
|
||||
function createPostgresConfig() {
|
||||
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
|
||||
@ -12,6 +14,39 @@ function setPostgresPassword() {
|
||||
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
|
||||
echo "usage: <import|run>"
|
||||
echo "commands:"
|
||||
@ -20,6 +55,7 @@ if [ "$#" -ne 1 ]; then
|
||||
echo "environment variables:"
|
||||
echo " THREADS: defines number of threads used for importing / tile rendering"
|
||||
echo " UPDATES: consecutive updates (enabled/disabled)"
|
||||
echo " RENDERERAPP: select render application renderd (default) or tirex"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@ -67,6 +103,9 @@ if [ "$1" = "import" ]; then
|
||||
fi
|
||||
|
||||
if [ "$1" = "run" ]; then
|
||||
# add handler for signal SIHTERM
|
||||
trap 'sighandler_TERM' 15
|
||||
|
||||
# Clean /tmp
|
||||
rm -rf /tmp/*
|
||||
|
||||
@ -92,9 +131,22 @@ if [ "$1" = "run" ]; then
|
||||
/etc/init.d/cron start
|
||||
fi
|
||||
|
||||
# Run
|
||||
sudo -u renderer renderd -f -c /usr/local/etc/renderd.conf
|
||||
service postgresql stop
|
||||
if [ "$RENDERERAPP" = "renderd" ]; then
|
||||
# start renderd
|
||||
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
|
||||
fi
|
||||
|
||||
Loading…
Reference in New Issue
Block a user