Skip to content

Commit b6e737e

Browse files
Jens Hasslerwiktorn
Jens Hassler
authored andcommitted
configure "allow-duplicate-queries" through env var
fix default healthcheck script
1 parent 748cd02 commit b6e737e

File tree

3 files changed

+29
-7
lines changed

3 files changed

+29
-7
lines changed

README.md

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
# How to use this image
32

43
By default, this image will clone an existing Overpass server for the whole planet, and make it available at `http://localhost/api/interpreter`.
@@ -24,17 +23,17 @@ The following enviroment variables can be used to customize the setup:
2423
* `OVERPASS_USE_AREAS` - if `false` initial area generation and the area updater process will be disabled. Default `true`.
2524
* `OVERPASS_HEALTHCHECK` - shell commands to execute to verify that image is healthy. `exit 1` in case of failures, `exit 0` when container is healthy. Default healthcheck queries overpass and verifies that there is reponse returned
2625
* `OVERPASS_STOP_AFTER_INIT` - if `false` the container will keep runing after init is complete. Otherwise container will be stopped after initialization process is complete. Default `true`
26+
* `OVERPASS_ALLOW_DUPLICATE_QUERIES` - if `yes`, duplicate queries (same query from the same IP address) will be allowed. Default `no`.
2727

2828
### Modes
2929

3030
Image works in two modes `init` or `clone`. This affects how the instance gets initialized:
3131

3232
* `init` - OSM data is downloaded from `OVERPASS_PLANET_URL`, which can be a full planet or partial planet dump.
33-
This file will then be indexed by Overpass and later updated using `OVERPASS_DIFF_URL`.
34-
33+
This file will then be indexed by Overpass and later updated using `OVERPASS_DIFF_URL`.
3534
* `clone` - data is copied from an existing server, given by `OVERPASS_CLONE_SOURCE`, and then updated using `OVERPASS_DIFF_URL`.
36-
This mode is faster to set up, as the OSM planet file is already indexed.
37-
The default clone source provides an Overpass instance using minute diffs covering the whole world (hourly or daily diffs will not work with this image).
35+
This mode is faster to set up, as the OSM planet file is already indexed.
36+
The default clone source provides an Overpass instance using minute diffs covering the whole world (hourly or daily diffs will not work with this image).
3837

3938
### Running
4039

@@ -55,10 +54,13 @@ All data resides within the `/db` directory in the container.
5554
For convenience, a [`docker-compose.yml` template](./docker-compose.yml) is included.
5655

5756
# Examples
57+
5858
## Overpass instance covering part of the world
59+
5960
In this example the Overpass instance will be initialized with a planet file for Monaco downloaded from Geofabrik.
6061
Data will be stored in folder`/big/docker/overpass_db/` on the host machine and will not contain metadata as this example uses public Geofabrik extracts that do not contain metadata (such as changeset and user).
6162
Overpass will be available on port 12345 on the host machine.
63+
6264
```
6365
docker run \
6466
-e OVERPASS_META=yes \
@@ -73,8 +75,10 @@ docker run \
7375
```
7476

7577
## Overpass clone covering whole world
78+
7679
In this example Overpass instance will be initialized with data from main Overpass instance and updated with master planet diffs.
7780
Data will be stored in `/big/docker/overpass_clone_db/` on the host machine and the API will be available on port 12346 on the host machine.
81+
7882
```
7983
docker run \
8084
-e OVERPASS_META=yes \
@@ -88,10 +92,12 @@ docker run \
8892
```
8993

9094
## Overpass instance covering part of the world using cookie
95+
9196
In this example Overpass instance will be initialized with planet file for Monaco downloaded from internal Geofabrik server.
9297
Data will be stored in `/big/docker/overpass_db/` on the host machine and the API will be available on port 12347 on the host machine.
9398

9499
Prepare file with your credentials `/home/osm/oauth-settings.json`:
100+
95101
```json
96102
{
97103
"user": "your-username",
@@ -122,7 +128,9 @@ docker run \
122128
```
123129

124130
## Healthcheck checking that instance is up-to-date
131+
125132
Using following environment variable:
133+
126134
```
127135
-e OVERPASS_HEALTHCHECK='
128136
OVERPASS_RESPONSE=$(curl --noproxy "*" -s "http://localhost/api/interpreter?data=\[out:json\];node(1);out;" | jq -r .osm3s.timestamp_osm_base)
@@ -135,10 +143,11 @@ Using following environment variable:
135143
echo "Overpass date: ${OVERPASS_RESPONSE}"
136144
'
137145
```
138-
healthcheck will verify the date of last update of Overpass instance and if data in instance are earlier than two days ago, healthcheck will fail.
139146

147+
healthcheck will verify the date of last update of Overpass instance and if data in instance are earlier than two days ago, healthcheck will fail.
140148

141149
# How to use Overpass after deploying using above examples
150+
142151
The Overpass API will be exposed on the port exposed by `docker run` - for example `http://localhost:12346/api/interpreter`.
143152

144153
You may then use this directly as an Overpass API url, or use it within [Overpass Turbo](http://overpass-turbo.eu/).

bin/dispatcher_start.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,13 @@ fi
1515
if [[ -n ${OVERPASS_TIME} ]]; then
1616
DISPATCHER_ARGS+=("--time=${OVERPASS_TIME}")
1717
fi
18+
1819
if [[ -n ${OVERPASS_SPACE} ]]; then
1920
DISPATCHER_ARGS+=("--space=${OVERPASS_SPACE}")
2021
fi
2122

23+
if [[ -n ${OVERPASS_ALLOW_DUPLICATE_QUERIES} ]]; then
24+
DISPATCHER_ARGS+=("--allow-duplicate-queries=${OVERPASS_ALLOW_DUPLICATE_QUERIES}")
25+
fi
26+
2227
find /db/db -type s -print0 | xargs -0 --no-run-if-empty rm && /app/bin/dispatcher "${DISPATCHER_ARGS[@]}"

docker-healthcheck.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22

33
set -e -o pipefail
44

5-
OVERPASS_HEALTHCHECK=${OVERPASS_HEALTHCHECK:-'curl --noproxy "*" -qf "http://localhost/api/interpreter?data=\[out:json\];node(1);out;" | jq ".generator" |grep -q Overpass || exit 1'}
5+
NODE_ID=1
6+
7+
# if we allow duplicate queries, the healthcheck will fail because it always fetches node id 1
8+
# if that is the case (default), we query a random node
9+
if [[ ! -n ${OVERPASS_ALLOW_DUPLICATE_QUERIES} || ${OVERPASS_ALLOW_DUPLICATE_QUERIES} == "no" ]]; then
10+
NODE_ID=$(shuf -i 1-10000000 -n 1)
11+
fi
12+
13+
OVERPASS_HEALTHCHECK=${OVERPASS_HEALTHCHECK:-'curl --noproxy "*" -qf "http://localhost/api/interpreter?data=\[out:json\];node(${NODE_ID});out;" | jq ".generator" |grep -q Overpass || exit 1'}
614

715
eval "${OVERPASS_HEALTHCHECK}"

0 commit comments

Comments
 (0)