Skip to content

Commit

Permalink
Merge pull request #24 from rtuszik/rev.4
Browse files Browse the repository at this point in the history
fix: fix country code env var requirement, default update strategy
  • Loading branch information
rtuszik authored Jan 12, 2025
2 parents 659c019 + da3ea0e commit 8d81326
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
5 changes: 2 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ services:
photon:
image: rtuszik/photon-docker:latest
container_name: "photon-docker"

environment:
- UPDATE_STRATEGY=SEQUENTIAL
- UPDATE_STRATEGY=PARALLEL
- UPDATE_INTERVAL=24h
- LOG_LEVEL=INFO # Options: DEBUG, INFO, ERROR
- LOG_LEVEL=INFO # Options: DEBUG, INFO, ERROR
# - COUNTRY_CODE=zw
volumes:
- photon_data:/photon/photon_data
Expand Down
16 changes: 7 additions & 9 deletions start-photon.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
DATA_DIR="/photon"
INDEX_DIR="/photon/photon_data/elasticsearch"
TEMP_DIR="/photon/photon_data/temp"
UPDATE_STRATEGY="${UPDATE_STRATEGY:-SEQUENTIAL}"
UPDATE_STRATEGY="${UPDATE_STRATEGY:-PARALLEL}"
UPDATE_INTERVAL="${UPDATE_INTERVAL:-24h}"
LOG_LEVEL="${LOG_LEVEL:-INFO}"
MIN_DISK_SPACE=100000000 # 100GB in bytes
Expand Down Expand Up @@ -124,10 +124,9 @@ download_index() {

mkdir -p "$TEMP_DIR"

if [[ -n "${COUNTRY_CODE}" ]]; then
local url="https://download1.graphhopper.com/public/extracts/by-country-code/${COUNTRY_CODE}/photon-db-${COUNTRY_CODE}-latest"
else
local url="https://download1.graphhopper.com/public/photon-db-latest"
local url="https://download1.graphhopper.com/public/photon-db-latest"
if [[ -n "${COUNTRY_CODE:-}" ]]; then
url="https://download1.graphhopper.com/public/extracts/by-country-code/${COUNTRY_CODE}/photon-db-${COUNTRY_CODE}-latest"
fi

log_info "Downloading index from $url"
Expand Down Expand Up @@ -271,10 +270,9 @@ main() {
if [ -d "$INDEX_DIR" ]; then
if verify_structure "$DATA_DIR"; then
log_info "Found existing valid elasticsearch index"
local url="https://download1.graphhopper.com/public/photon-db-latest"
if [[ -n "${COUNTRY_CODE}" ]]; then
local url="https://download1.graphhopper.com/public/extracts/by-country-code/${COUNTRY_CODE}/photon-db-${COUNTRY_CODE}-latest"
else
local url="https://download1.graphhopper.com/public/photon-db-latest"
url="https://download1.graphhopper.com/public/extracts/by-country-code/${COUNTRY_CODE}/photon-db-${COUNTRY_CODE}-latest"
fi

if check_remote_index "$url"; then
Expand Down Expand Up @@ -309,7 +307,7 @@ main() {
log_info "Sleeping for ${update_seconds} seconds until next update"
sleep "$update_seconds"
log_info "Checking for index updates"
if [[ -n "${COUNTRY_CODE}" ]]; then
if [[ -n "${COUNTRY_CODE:-}" ]]; then
local url="https://download1.graphhopper.com/public/extracts/by-country-code/${COUNTRY_CODE}/photon-db-${COUNTRY_CODE}-latest"
else
local url="https://download1.graphhopper.com/public/photon-db-latest"
Expand Down

0 comments on commit 8d81326

Please sign in to comment.