From 17559cfa3018a7884008f9eedaca7e528c1077d2 Mon Sep 17 00:00:00 2001 From: Carlo Mion Date: Tue, 16 Apr 2024 11:19:41 +0200 Subject: [PATCH] ci: use tail with grep apply fix also to version 4.3 --- .github/workflows/ci.yml | 12 ++++++++---- 4.3/start.sh | 8 +++++++- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dc62af10..40a18c9a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -118,9 +118,10 @@ jobs: -p 8004:8080 \ --name nominatim \ nominatim & + ./assert-non-empty-json "http://localhost:8004/search.php?q=avenue%20pasteur" echo "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."' docker stop nominatim - name: Check UPDATE_MODE=continuous with bind-mount @@ -141,7 +142,7 @@ jobs: ./assert-non-empty-json "http://localhost:8004/search.php?q=avenue%20pasteur" echo "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."' docker stop nominatim - name: Check import full style @@ -202,18 +203,21 @@ jobs: - name: Check for clean shutdown working-directory: .github/workflows run: |- - docker run --detach --rm \ + docker run -i \ -e PBF_URL=http://download.geofabrik.de/europe/monaco-latest.osm.pbf \ -e USER_AGENT=${{matrix.nominatim.user_agent}} \ -p 8009:8080 \ --name nominatim \ - 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}}') + # Cleanup container + docker rm nominatim + echo "container exited with exit-code $CONTAINER_EXIT_CODE" test "$CONTAINER_EXIT_CODE" -eq 0 - name: Check when using FREEZE diff --git a/4.3/start.sh b/4.3/start.sh index c59a4c85..0fdd86cf 100755 --- a/4.3/start.sh +++ b/4.3/start.sh @@ -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