-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
delay-prediction-service: refactor scripts, add cleanup timed task #54
Open
derhuerst
wants to merge
2
commits into
stadtnavi:master
Choose a base branch
from
derhuerst:delay-prediction-service-cleanup
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#! /bin/bash -e | ||
|
||
DOCKER_IMAGE=stadtnavi/delay-prediction-service:{{ delay_prediction_service_version }} | ||
|
||
docker pull ${DOCKER_IMAGE} | ||
docker run --rm -i \ | ||
--network delay \ | ||
-v delay-prediction-service-data:/app/data \ | ||
-e TIMEZONE=Europe/Berlin \ | ||
-e LOCALE=de-DE \ | ||
-e GTFS_NAME=vvs \ | ||
-e GTFS_URL='https://www.openvvs.de/dataset/e66f03e4-79f2-41d0-90f1-166ca609e491/resource/bfbb59c7-767c-4bca-bbb2-d8d32a3e0378/download/google_transit.zip' \ | ||
-e PGHOST="delay-postgis" \ | ||
-e PGUSER="{{ delay_postgres_user }}" \ | ||
-e PGPASSWORD="{{ delay_postgres_password }}" \ | ||
-e PGDATABASE="{{ delay_postgres_db }}" \ | ||
-e LOG_LEVEL=debug \ | ||
--name delay-prediction-service-build \ | ||
${DOCKER_IMAGE} \ | ||
./scripts/build.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#! /bin/bash -e | ||
|
||
DOCKER_IMAGE=stadtnavi/delay-prediction-service:{{ delay_prediction_service_version }} | ||
|
||
docker pull ${DOCKER_IMAGE} | ||
docker run --rm -i \ | ||
--network delay \ | ||
-v delay-prediction-service-data:/app/data \ | ||
-e TIMEZONE=Europe/Berlin \ | ||
-e LOCALE=de-DE \ | ||
-e GTFS_NAME=vvs \ | ||
-e PGHOST="delay-postgis" \ | ||
-e PGUSER="{{ delay_postgres_user }}" \ | ||
-e PGPASSWORD="{{ delay_postgres_password }}" \ | ||
-e PGDATABASE="{{ delay_postgres_db }}" \ | ||
-e LOG_LEVEL=debug \ | ||
--name delay-prediction-service-cleanup \ | ||
${DOCKER_IMAGE} \ | ||
./scripts/cleanup.js |
17 changes: 17 additions & 0 deletions
17
roles/delay-prediction-service/templates/delay-prediction-cleanup.service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
[Unit] | ||
Description=delete old delay-prediction-service data | ||
Requires=docker.service | ||
After=docker.service | ||
|
||
# restart once within 20m to handle an intermittent network failure gracefully | ||
StartLimitIntervalSec=1200 | ||
StartLimitBurst=1 | ||
|
||
[Service] | ||
ExecStart=/var/delay-prediction/cleanup | ||
Restart=on-failure | ||
|
||
ExecStopPost=/bin/sh -c 'if [ "$$EXIT_STATUS" != "0" ]; then send-to-matrix "delay-prediction-cleanup failed on {{ inventory_hostname }}. EXIT_STATUS:$$EXIT_STATUS, SERVICE_RESULT:$$SERVICE_RESULT, EXIT_CODE:$$EXIT_CODE"; fi' | ||
|
||
[Install] | ||
WantedBy=multi-user.target |
9 changes: 9 additions & 0 deletions
9
roles/delay-prediction-service/templates/delay-prediction-cleanup.timer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[Unit] | ||
Description=delete old delay-prediction-service data every night | ||
|
||
[Timer] | ||
OnCalendar=*-*-* 04:30:00 | ||
Persistent=true | ||
|
||
[Install] | ||
WantedBy=timers.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#! /bin/bash -e | ||
|
||
docker stop --time 5 delay-prediction-service |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This and the timer file won't be copied to the server. You need to add them to the "Install systemd files" section.