Skip to content

Commit

Permalink
Merge pull request #554 from carlomion/bugfix/shutdown_no_replication
Browse files Browse the repository at this point in the history
Bugfix: correctly shutdown even without replication
  • Loading branch information
philipkozeny authored Apr 17, 2024
2 parents 6b2c291 + 04466a2 commit b24d9e0
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 23 deletions.
47 changes: 31 additions & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
-p 8001:8080 \
--name nominatim \
nominatim &
sleep 120
./assert-non-empty-json "http://localhost:8001/search.php?q=avenue%20pasteur"
docker exec -i nominatim sudo -u nominatim nominatim replication --project-dir /nominatim --once
./assert-non-empty-json "http://localhost:8001/search.php?q=avenue%20pasteur"
Expand All @@ -70,7 +70,7 @@ jobs:
-v nominatim-data:/var/lib/postgresql/14/main \
-p 8002:8080 \
nominatim &
sleep 120
./assert-non-empty-json "http://localhost:8002/search.php?q=avenue%20pasteur"
- name: Import with bind-mount, container restart & update
Expand All @@ -84,7 +84,7 @@ jobs:
-p 8003:8080 \
--name nominatim \
nominatim &
sleep 120
./assert-non-empty-json "http://localhost:8003/search.php?q=avenue%20pasteur"
# Stop container
Expand All @@ -98,7 +98,7 @@ jobs:
-p 8004:8080 \
--name nominatim \
nominatim &
sleep 25
./assert-non-empty-json "http://localhost:8004/search.php?q=avenue%20pasteur"
docker exec -i nominatim sudo -u nominatim nominatim replication --project-dir /nominatim --once
Expand All @@ -116,10 +116,10 @@ jobs:
-p 8004:8080 \
--name nominatim \
nominatim &
sleep 120
./assert-non-empty-json "http://localhost:8004/search.php?q=avenue%20pasteur"
echo -n "check replication log for Update completed. Count:"
docker exec -i nominatim grep -c 'Update completed.' /var/log/replication.log
docker exec nominatim /bin/bash -c 'tail -f /var/log/replication.log | grep -m 1 -c "Update completed."'
- name: UPDATE_MODE=continuous with bind-mount
commands: |-
Expand All @@ -133,10 +133,10 @@ jobs:
-p 8004:8080 \
--name nominatim \
nominatim &
sleep 120
./assert-non-empty-json "http://localhost:8004/search.php?q=avenue%20pasteur"
echo -n "check replication log for Update completed. Count:"
docker exec -i nominatim grep -c 'Update completed.' /var/log/replication.log
docker exec nominatim /bin/bash -c 'tail -f /var/log/replication.log | grep -m 1 -c "Update completed."'
- name: Import full style
commands: |-
Expand All @@ -146,7 +146,7 @@ jobs:
-e IMPORT_STYLE=full \
-p 8005:8080 \
nominatim &
sleep 120
./assert-non-empty-json "http://localhost:8005/search.php?q=hotel%20de%20paris"
- name: Import admin style
Expand All @@ -157,7 +157,7 @@ jobs:
-e IMPORT_STYLE=admin \
-p 8006:8080 \
nominatim &
sleep 120
./assert-empty-json "http://localhost:8006/search.php?q=hotel%20de%20paris"
- name: Import with PBF_PATH
Expand All @@ -171,7 +171,7 @@ jobs:
-p 8007:8080 \
--name nominatim \
nominatim &
sleep 120
./assert-non-empty-json "http://localhost:8007/search.php?q=avenue%20pasteur"
- name: REPLICATION_URL is blank
Expand All @@ -180,7 +180,7 @@ jobs:
-e PBF_URL=http://download.geofabrik.de/europe/monaco-latest.osm.pbf \
-p 8008:8080 \
nominatim &
sleep 120
./assert-non-empty-json "http://localhost:8008/search.php?q=avenue%20pasteur"
- name: FREEZE
Expand All @@ -190,7 +190,7 @@ jobs:
-e FREEZE="true" \
-p 8009:8080 \
nominatim &
sleep 120
./assert-non-empty-json "http://localhost:8009/search.php?q=avenue%20pasteur"
- name: GB postcode import
Expand All @@ -200,7 +200,7 @@ jobs:
-e IMPORT_GB_POSTCODES="true" \
-p 8010:8080 \
nominatim &
sleep 600
./assert-non-empty-json "http://localhost:8010/search.php?postalcode=LE15+8TX"
./assert-non-empty-json "http://localhost:8010/search.php?postalcode=PE9+3SY"
./assert-non-empty-json "http://localhost:8010/search.php?postalcode=PE9+4ES"
Expand All @@ -212,10 +212,25 @@ jobs:
-e REVERSE_ONLY="true" \
-p 8011:8080 \
nominatim &
sleep 120
./assert-reverse-only "http://localhost:8011/search.php?q=avenue%20pasteur"
./assert-non-empty-json "http://localhost:8011/reverse.php?lat=43.734&lon=7.42&format=jsonv2"
- name: Check for clean shutdown
commands: |-
docker run --detach --rm \
-e PBF_URL=http://download.geofabrik.de/europe/monaco-latest.osm.pbf \
-p 8009:8080 \
--name nominatim \
nominatim
./assert-non-empty-json "http://localhost:8009/search.php?q=avenue%20pasteur"
# Shutdown the container
docker stop -t 60 nominatim
# Verify that the exit code is zero
CONTAINER_EXIT_CODE=$(docker inspect nominatim --format='{{.State.ExitCode}}')
test "$CONTAINER_EXIT_CODE" -eq 0
steps:
- name: Download artifact
uses: actions/download-artifact@v4
Expand Down
8 changes: 7 additions & 1 deletion 4.3/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,14 @@ replicationpid=0
stopServices() {
service apache2 stop
service postgresql stop
kill $replicationpid
# Check if the replication process is active
if [ $replicationpid -ne 0 ]; then
echo "Shutting down replication process"
kill $replicationpid
fi
kill $tailpid
# Force exit code 0 to signal a succesfull shutdown to Docker
exit 0
}
trap stopServices SIGTERM TERM INT

Expand Down
10 changes: 5 additions & 5 deletions 4.4/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ ENV LANG=C.UTF-8

WORKDIR /app

RUN true \
RUN \
--mount=type=cache,target=/var/cache/apt \
# Do not start daemons after installation.
&& echo '#!/bin/sh\nexit 101' > /usr/sbin/policy-rc.d \
echo '#!/bin/sh\nexit 101' > /usr/sbin/policy-rc.d \
&& chmod +x /usr/sbin/policy-rc.d \
# Install all required packages.
&& apt-get -y update -qq \
Expand Down Expand Up @@ -75,7 +76,8 @@ RUN true \
&& echo "listen_addresses='*'" >> /etc/postgresql/14/main/postgresql.conf

# Osmium install to run continuous updates.
RUN pip3 install osmium
RUN --mount=type=cache,target=/root/.cache/pip \
pip3 install osmium

# Nominatim install.
ARG NOMINATIM_VERSION
Expand Down Expand Up @@ -107,12 +109,10 @@ RUN true \
liblua*-dev \
postgresql-server-dev-14 \
nlohmann-json3-dev \
&& apt-get clean \
# Clear temporary files and directories.
&& rm -rf \
/tmp/* \
/var/tmp/* \
/root/.cache \
/app/src/.git \
/var/lib/apt/lists/* \
# Remove nominatim source and build directories
Expand Down
8 changes: 7 additions & 1 deletion 4.4/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,14 @@ replicationpid=0
stopServices() {
service apache2 stop
service postgresql stop
kill $replicationpid
# Check if the replication process is active
if [ $replicationpid -ne 0 ]; then
echo "Shutting down replication process"
kill $replicationpid
fi
kill $tailpid
# Force exit code 0 to signal a succesfull shutdown to Docker
exit 0
}
trap stopServices SIGTERM TERM INT

Expand Down

0 comments on commit b24d9e0

Please sign in to comment.