Skip to content

Commit 1440245

Browse files
committed
Upload only .db files from the main directory
Update taginfo script and readme Update taginfo Path to taginfo to sabe db files Install cron in taginfo Fetch data if requiere - taginfo Update config
1 parent e58293f commit 1440245

File tree

4 files changed

+47
-33
lines changed

4 files changed

+47
-33
lines changed

envs/.env.taginfo.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,6 @@ TAGINFO_PROJECT_REPO=https://github.com/OpenHistoricalMap/taginfo-projects.git
1414
DOWNLOAD_DB='languages wiki'
1515
CREATE_DB='db projects chronology'
1616
TAGINFO_DB_BASE_URL=https://planet.openhistoricalmap.org.s3.amazonaws.com/taginfo
17+
AWS_S3_BUCKET=planet-staging.openhistoricalmap.org
18+
ENVIRONMENT=staging
19+
FETCH_DB_FILES=true

images/taginfo/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ RUN apt-get update && apt-get install -y \
2525
jq \
2626
python3-pip \
2727
wget \
28+
cron \
2829
&& apt-get clean \
2930
&& rm -rf /var/lib/apt/lists/*
3031

images/taginfo/README.md

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,43 @@
11
# OSM-Seed taginfo
22

3-
We build a docker container for taginfo software, the container will start the web service and also process required files to create databases.
3+
Docker container for taginfo that runs the web service and processes PBF files to create databases.
44

55
## Environment Variables
66

7-
All environment variables are located at [`.env.taginfo.example`](./../../envs/.env.taginfo.example), make a copy and name it as `.env.tagninfo` to use in osm-seed.
7+
Copy [`.env.taginfo.example`](./../../envs/.env.taginfo.example) to `.env.taginfo` and configure:
88

9-
- `URL_PLANET_FILE_STATE`: Url to the state file, that contains the URL for the latest planet PBF file. e.g [`state.txt`](https://planet.openhistoricalmap.org.s3.amazonaws.com/planet/state.txt), This is no required in case you set the `URL_PLANET_FILE` env var
9+
### Planet Files
10+
- `URL_PLANET_FILE_STATE`: URL to state file with latest planet PBF URL (optional if `URL_PLANET_FILE` is set)
11+
- `URL_HISTORY_PLANET_FILE_STATE`: URL to state file with latest history PBF URL (optional if `URL_HISTORY_PLANET_FILE` is set)
12+
- `URL_PLANET_FILE`: Direct URL to planet PBF file
13+
- `URL_HISTORY_PLANET_FILE`: Direct URL to history PBF file
1014

11-
- `URL_HISTORY_PLANET_FILE_STATE`: Url to the full history state file, that contains the URL for the latest full history planet PBF file. e.g [`state.txt`](https://planet.openhistoricalmap.org.s3.amazonaws.com/planet/full-history/state.txt), This is no required in case you set the `URL_HISTORY_PLANET_FILE` env var
15+
### Database Configuration
16+
- `TAGINFO_DB_BASE_URL`: Base URL to download SQLite database files. Downloads: projects-cache.db, selection.db, taginfo-chronology.db, taginfo-db.db, taginfo-history.db, taginfo-languages.db, taginfo-master.db, taginfo-projects.db, taginfo-wiki.db, taginfo-wikidata.db
17+
- Example: `https://planet.openhistoricalmap.org.s3.amazonaws.com/taginfo`
1218

13-
- `URL_PLANET_FILE`: URL for the latest planet PBF file.
14-
- `URL_HISTORY_PLANET_FILE`: URL for the latest full history planet PBF file.
15-
- `TIME_UPDATE_INTERVAL` Interval time to update the databases, e.g: `50m` = every 50 minutes, `20h` = every 20 hours , `5d` = every 5 days
19+
- `DOWNLOAD_DB`: Which databases to download (e.g., `languages wiki` or `languages wiki projects chronology`)
1620

17-
The following env vars are required in the instance to update the values at: https://github.com/taginfo/taginfo/blob/master/taginfo-config-example.json
21+
- `CREATE_DB`: Which databases to create from PBF files (e.g., `db projects` or `db projects chronology`)
22+
- `db` requires `URL_PLANET_FILE` or `URL_PLANET_FILE_STATE`
23+
- `projects` requires `TAGINFO_PROJECT_REPO`
24+
- `chronology` requires `URL_PLANET_FILE` or `URL_HISTORY_PLANET_FILE`
1825

19-
- `OVERWRITE_CONFIG_URL`: config file with the values to update
26+
### Other
27+
- `TAGINFO_PROJECT_REPO`: Repository URL for taginfo projects (default: https://github.com/taginfo/taginfo-projects.git)
28+
- `OVERWRITE_CONFIG_URL`: URL to custom taginfo config JSON file
29+
- `INTERVAL_DOWNLOAD_DATA`: Interval to sync databases (e.g., `3600` for 1 hour, `7d` for 7 days)
2030

21-
- `DOWNLOAD_DB`: Taginfo instances need 7 Sqlite databases to start up the web service, all of them can be downloaded from https://taginfo.openstreetmap.org/download. Or if you can download only some of them you can pass herec. e.g DOWNLOAD_DB=`languages wiki`, or DOWNLOAD_DB=`languages wiki projects chronology`.
22-
23-
- `CREATE_DB`: If you want process you of data using the PBF files, you can pass the values. eg. CREATE_DB=`db projects` or CREATE_DB=`db projects chronology`.
24-
Note:
25-
- Value `db` require to pass `URL_PLANET_FILE` or `URL_PLANET_FILE_STATE`
26-
- Value `projects` require to pass `TAGINFO_PROJECT_REPO`
27-
- Value `chronology` require to pass `URL_PLANET_FILE` or `URL_HISTORY_PLANET_FILE`
28-
29-
#### Running taginfo container
31+
## Running
3032

3133
```sh
32-
# Docker compose
33-
docker-compose run taginfo
34-
35-
# Docker
36-
docker run \
37-
--env-file ./envs/.env.taginfo \
38-
-v ${PWD}/data/taginfo-data:/apps/data/ \
39-
--network osm-seed_default \
40-
-it osmseed-taginfo:v1
41-
```
34+
# Docker compose
35+
docker-compose run taginfo
36+
37+
# Docker
38+
docker run \
39+
--env-file ./envs/.env.taginfo \
40+
-v ${PWD}/data/taginfo-data:/usr/src/app/data \
41+
--network osm-seed_default \
42+
-it osmseed-taginfo:v1
43+
```

images/taginfo/start.sh

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,12 @@ process_data() {
4646
# wikidata/update.sh $DATADIR
4747
chronology/update.sh $DATADIR
4848
./update_all.sh $DATADIR
49-
# Move database files from subdirectories to main data directory
50-
aws s3 sync $DATADIR/ s3://$AWS_S3_BUCKET/taginfo/$ENVIRONMENT/ --exclude "*" --include "*.db"
49+
mv $DATADIR/*.db $DATADIR/
50+
mv $DATADIR/*/*.db $DATADIR/
51+
# if AWS_S3_BUCKET is set upload data
52+
if ! aws s3 ls "s3://$AWS_S3_BUCKET/taginfo" 2>&1 | grep -q 'An error occurred'; then
53+
aws s3 sync $DATADIR/ s3://$AWS_S3_BUCKET/taginfo/ --exclude "*" --include "*.db"
54+
fi
5155
}
5256

5357
# Compress files to download
@@ -105,22 +109,26 @@ download_db_files() {
105109

106110
sync_latest_db_version() {
107111
while true; do
108-
sleep "$INTERVAL_DOWNLOAD_DATA"
109112
download_db_files "$TAGINFO_DB_BASE_URL"
113+
sleep "$INTERVAL_DOWNLOAD_DATA"
110114
done
111115
}
112116

113117
start_web() {
114118
echo "Start...Taginfo web service"
115-
download_db_files "$TAGINFO_DB_BASE_URL"
116-
cd $WORKDIR/taginfo/web && ./taginfo.rb & sync_latest_db_version
119+
cd $WORKDIR/taginfo/web && ./taginfo.rb
117120
}
118121

119122
ACTION=$1
120123
# Overwrite the config file
121124
[[ ! -z ${OVERWRITE_CONFIG_URL} ]] && wget $OVERWRITE_CONFIG_URL -O /usr/src/app/taginfo-config.json
122125
updates_source_code
123126
if [ "$ACTION" = "web" ]; then
127+
# Start sync in background if enabled
128+
if [ "${FETCH_DB_FILES:-true}" = "true" ] && [ ! -z "$TAGINFO_DB_BASE_URL" ]; then
129+
sync_latest_db_version &
130+
fi
131+
# Start web server in foreground (so the loop can detect if it fails)
124132
start_web
125133
elif [ "$ACTION" = "data" ]; then
126134
process_data

0 commit comments

Comments
 (0)