From 0b36dbb49b3d339ac867e1241e0fbf695178047b Mon Sep 17 00:00:00 2001 From: Rub21 Date: Mon, 15 Apr 2024 18:13:25 -0500 Subject: [PATCH] Update script to sync lates version of taginfo data --- images/taginfo/start.sh | 29 +++++++++++++------ .../templates/taginfo/taginfo-deployment.yaml | 10 +++---- 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/images/taginfo/start.sh b/images/taginfo/start.sh index 5a46e099..db0226b9 100755 --- a/images/taginfo/start.sh +++ b/images/taginfo/start.sh @@ -14,7 +14,7 @@ updates_source_code() { # Function to replace the projects repo to get the projects information TAGINFO_PROJECT_REPO=${TAGINFO_PROJECT_REPO//\//\\/} sed -i -e 's/https:\/\/github.com\/taginfo\/taginfo-projects.git/'$TAGINFO_PROJECT_REPO'/g' $WORKDIR/taginfo/sources/projects/update.sh -} +} download_planet_files() { # Check if URL_PLANET_FILE_STATE exist and set URL_PLANET_FILE @@ -46,14 +46,13 @@ process_data() { mv $DATADIR/taginfo-*.db $DATADIR/ mv $DATADIR/*/taginfo-*.db $DATADIR/ # if BUCKET_NAME is set upload data - + if ! aws s3 ls "s3://$BUCKET_NAME/$ENVIRONMENT" 2>&1 | grep -q 'An error occurred'; then aws s3 sync $DATADIR/ s3://$AWS_S3_BUCKET/$ENVIRONMENT/ --exclude "*" --include "*.db" fi - } -# Compress files to download +# Compress files to download compress_files() { mkdir -p download for file in data/*; do @@ -61,13 +60,25 @@ compress_files() { done } -start_web() { - echo "Start...Taginfo web service" +download_db_files() { if ! aws s3 ls "s3://$BUCKET_NAME/$ENVIRONMENT" 2>&1 | grep -q 'An error occurred'; then - aws s3 sync s3://$AWS_S3_BUCKET/$ENVIRONMENT/ $DATADIR/ + aws s3 sync "s3://$BUCKET_NAME/$ENVIRONMENT/" "$DATADIR/" fi - compress_files & - cd $WORKDIR/taginfo/web && ./taginfo.rb + compress_files +} + + +sync_latest_db_version() { + while true; do + download_db_files + sleep "$INTERVAL_DOWNLOAD_DATA" + done +} + +start_web() { + echo "Start...Taginfo web service" + download_db_files + cd $WORKDIR/taginfo/web && ./taginfo.rb & sync_latest_db_version } ACTION=$1 diff --git a/osm-seed/templates/taginfo/taginfo-deployment.yaml b/osm-seed/templates/taginfo/taginfo-deployment.yaml index 1b8eb1b3..adc2d046 100644 --- a/osm-seed/templates/taginfo/taginfo-deployment.yaml +++ b/osm-seed/templates/taginfo/taginfo-deployment.yaml @@ -2,7 +2,7 @@ apiVersion: apps/v1 kind: Deployment metadata: - name: {{ template "osm-seed.fullname" . }}-taginfo + name: {{ .Release.Name }}-taginfo-web labels: app: {{ template "osm-seed.name" . }} component: web-deployment @@ -14,13 +14,13 @@ spec: matchLabels: app: {{ template "osm-seed.name" . }} release: {{ .Release.Name }} - run: {{ .Release.Name }}-taginfo + run: {{ .Release.Name }}-taginfo-web template: metadata: labels: app: {{ template "osm-seed.name" . }} release: {{ .Release.Name }} - run: {{ .Release.Name }}-taginfo + run: {{ .Release.Name }}-taginfo-web spec: containers: - name: {{ .Chart.Name }}-taginfo @@ -38,8 +38,8 @@ spec: httpGet: path: / port: 80 - initialDelaySeconds: 600 - timeoutSeconds: 300 + initialDelaySeconds: 60 + timeoutSeconds: 30 {{- if .Values.taginfo.resources.enabled }} resources: requests: