Skip to content

Commit

Permalink
Update script to sync lates version of taginfo data
Browse files Browse the repository at this point in the history
  • Loading branch information
Rub21 committed Apr 15, 2024
1 parent 9403df3 commit 0b36dbb
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 14 deletions.
29 changes: 20 additions & 9 deletions images/taginfo/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -46,28 +46,39 @@ 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
bzip2 -k -9 -c "$file" > "download/$(basename "$file").bz2"
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
Expand Down
10 changes: 5 additions & 5 deletions osm-seed/templates/taginfo/taginfo-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -38,8 +38,8 @@ spec:
httpGet:
path: /
port: 80
initialDelaySeconds: 600
timeoutSeconds: 300
initialDelaySeconds: 60
timeoutSeconds: 30
{{- if .Values.taginfo.resources.enabled }}
resources:
requests:
Expand Down

0 comments on commit 0b36dbb

Please sign in to comment.