Skip to content
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

centralized rabbitmq, ocpdb update #291

Merged
merged 5 commits into from
Jan 3, 2025
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -99,23 +99,26 @@ GEOSERVER_MAXIMUM_MEMORY=4G
# In prod, should switch to PRODUCTION_LOGGING. For other logging profiles see: https://docs.geoserver.org/stable/en/user/configuration/globalsettings.html#config-globalsettings-log-profile
GEOSERVER_LOGGING_PROFILE=DEFAULT_LOGGING

# RabbitMQ for OCPDB and ParkAPI
RABBITMQ_VERSION=rabbitmq:3.13

# ocpdb
OCPDB_API_PORT=7000
OCPDB_POSTGRES_USER=ocpdb
OCPDB_POSTGRES_DB=ocpdb
OCPDB_POSTGRES_HOST=ocpdb-db
OCPDB_CELERY_BROKER_URL=amqp://ocpdb-rabbitmq
OCPDB_CELERY_BROKER_URL=amqp://rabbitmq/ocpdb
OCPDB_PRIVACY_URL=https://www.nvbw.de/datenschutz
OCPDB_LEGAL_NOTICE_URL=https://www.nvbw.de/impressum
OCPDB_IMAGE=ghcr.io/binary-butterfly/ocpdb:1.0.0
OCPDB_IMAGE=ghcr.io/binary-butterfly/ocpdb:1.2.1
OCPDB_DB_IMAGE=postgis/postgis:15-3.4-alpine

# ParkAPI
PARK_API_API_PORT=7500
PARK_API_POSTGRES_USER=park-api
PARK_API_POSTGRES_DB=park-api
PARK_API_POSTGRES_HOST=park-api-db
PARK_API_CELERY_BROKER_URL=amqp://park-api-rabbitmq
PARK_API_CELERY_BROKER_URL=amqp://rabbitmq/park-api
PARK_API_IMAGE=ghcr.io/parkendd/park-api-v3:0.16.2
PARK_API_DB_IMAGE=postgis/postgis:15-3.4-alpine

Expand Down
14 changes: 13 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,16 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
## Unreleased

### Added
- GeoServer: added ferry and furnicular to `mdbw_transit_stations_default` and `mdbw_transit_routes_default` gtfs styles
- GeoServer: added ferry and funicular to `mdbw_transit_stations_default` and `mdbw_transit_routes_default` gtfs styles
- OCPDB 1.2 with Stadtwerke Stuttgart
- OCPDB 1.2 with cron mechanisms for permanent data pulling

### Changed

- Centralize rabbitmq for better performance
- Improve rabbitmq healthcheck for better performance
- OCPDB 1.2 with BNetzA Import Fix
the-infinity marked this conversation as resolved.
Show resolved Hide resolved


## 2024-12-20

Expand All @@ -18,6 +27,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
### Changed
- remove obsolete GBFS providers tier_basel, tier_bern, tier_stgallen, tier_winterthur, tier_zurich


## 2024-12-11

### Added
Expand All @@ -26,6 +36,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
### Changed
- VRS parking providers obtain new Mobilithek subscription ids


## 2024-12-10

### Added
Expand All @@ -36,6 +47,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),

- new namespace for GBFS feed voi_de to avoid conflict with voi_ch


## 2024-12-04

### Changed
Expand Down
55 changes: 29 additions & 26 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ x-ocpdb-defaults: &ocpdb-defaults
depends_on:
ocpdb-db:
condition: service_healthy
ocpdb-rabbitmq:
rabbitmq:
condition: service_healthy
volumes:
- ./etc/ocpdb/config.yaml:/app/config.yaml
Expand All @@ -40,7 +40,7 @@ x-park-api-defaults: &park-api-defaults
depends_on:
park-api-db:
condition: service_healthy
park-api-rabbitmq:
rabbitmq:
condition: service_healthy
volumes:
- ./etc/park-api/config.yaml:/app/config.yaml
Expand All @@ -49,20 +49,6 @@ x-park-api-defaults: &park-api-defaults
- ./var/park-api/logs:/app/logs
- ./var/park-api/temp:/app/temp

x-generic-rabbitmq: &generic-rabbitmq
networks: [ipl]
image: rabbitmq:3.13
user: rabbitmq # required due eacces-issue: https://github.com/docker-library/rabbitmq/issues/318
environment:
# Disable spammy logging
RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS: '-rabbit log [{console,[{level,warning}]}]'
healthcheck:
test: rabbitmq-diagnostics -q ping
interval: 3s
timeout: 1s
retries: 20
restart: unless-stopped

services:
# Traefik is our ingress: requests enter our infrastructure through it.
# It is an HTTP reverse proxy, discovering available services (and their containers)
Expand Down Expand Up @@ -204,10 +190,10 @@ services:
restart: unless-stopped
healthcheck:
test: ps aux | grep -q 'x2gbfs\.x2gbfs' || exit 1
# If you want to wait until all feeds have been generated
# before depending lamassu starts subscribing them,
# If you want to wait until all feeds have been generated
# before depending lamassu starts subscribing them,
# configure an appropriate startup_period, e.g. 60s
# Otherwise, lamassu might update them only after the
# Otherwise, lamassu might update them only after the
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick]

It would be great if you could remove this unrelated formatting change from the commit(s).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's actually auto-cleanup by my IDE, cannot really remove it without disabling that feature completely.

# update interval period has passed, which for test might
# last several hours.
start_interval: ${X2GBFS_HEALTHCHECK_START_INTERVAL:-1s}
Expand Down Expand Up @@ -711,6 +697,24 @@ services:
- "traefik.http.services.gtfs-api-docs.loadbalancer.server.port=8080"
restart: unless-stopped

rabbitmq:
networks: [ipl]
image: ${RABBITMQ_VERSION}
user: rabbitmq # required due eacces-issue: https://github.com/docker-library/rabbitmq/issues/318
environment:
# Disable spammy logging
RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS: '-rabbit log [{console,[{level,warning}]}]'
healthcheck:
test: rabbitmq-diagnostics -q ping
interval: 30s
start_period: 20s
start_interval: 5s
timeout: 10s
volumes:
- ./etc/rabbitmq/rabbitmq.conf:/etc/rabbitmq/rabbitmq.conf
- ./etc/rabbitmq/definitions.json:/etc/rabbitmq/definitions.json
restart: unless-stopped

ocpdb-flask:
<<: *ocpdb-defaults
command: ["gunicorn", "--bind", "0.0.0.0:5000", "webapp.entry_point_gunicorn:app"]
Expand All @@ -729,9 +733,14 @@ services:
restart: unless-stopped
command: ["celery", "-A", "webapp.entry_point_celery", "worker", "-c", "2"]

ocpdb-heartbeat:
<<: *ocpdb-defaults
restart: unless-stopped
command: ["celery", "-A", "webapp.entry_point_celery", "beat", "-s", "/tmp/celerybeat-schedule"]

ocpdb-init:
<<: *ocpdb-defaults
command: ["sh", "-c", "flask db upgrade && flask bnetza import-web"]
command: ["sh", "-c", "flask db upgrade && flask source fetch-all"]

ocpdb-db:
networks: [ipl]
Expand All @@ -749,9 +758,6 @@ services:
retries: 3
restart: unless-stopped

ocpdb-rabbitmq:
<<: *generic-rabbitmq

park-api-flask:
<<: *park-api-defaults
restart: unless-stopped
Expand Down Expand Up @@ -795,9 +801,6 @@ services:
retries: 3
restart: unless-stopped

park-api-rabbitmq:
<<: *generic-rabbitmq

sftp:
image: ${SFTP_IMAGE}
networks: [ipl]
Expand Down
7 changes: 6 additions & 1 deletion etc/ocpdb/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,9 @@ OPENAPI_SERVERS:
# So far, we don't have credentials, so we can put REMOTE_SERVERS here
REMOTE_SERVERS:
BNETZA:
url: https://data.bundesnetzagentur.de/Bundesnetzagentur/SharedDocs/Downloads/DE/Sachgebiete/Energie/Unternehmen_Institutionen/E_Mobilitaet/Ladesaeulenregister.xlsx
url: https://data.bundesnetzagentur.de/Bundesnetzagentur/SharedDocs/Downloads/DE/Sachgebiete/Energie/Unternehmen_Institutionen/E_Mobilitaet/Ladesaeulenregister_01122024.xlsx
SW_STUTTGART:
url: 'https://new-poi.chargecloud.de'

AUTO_FETCH_SOURCES:
- sw_stuttgart
57 changes: 57 additions & 0 deletions etc/rabbitmq/definitions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
"permissions": [
{
"configure": ".*",
"read": ".*",
"user": "guest",
"vhost": "/",
"write": ".*"
},
{
"configure": ".*",
"read": ".*",
"user": "guest",
"vhost": "ocpdb",
"write": ".*"
},
{
"configure": ".*",
"read": ".*",
"user": "guest",
"vhost": "park-api",
"write": ".*"
}
],
"rabbit_version": "3.13.7",
"rabbitmq_version": "3.13.7",
"users": [
{
"hashing_algorithm": "rabbit_password_hashing_sha256",
"name": "guest",
"password_hash": "jJ6i6IgumvqlsjiFXbmB57Kr1K4fXCsNVk+Wrw4r9Rx+/6kq",
"tags": [
"administrator"
]
}
],
"vhosts": [
{
"metadata": {
"description": "Default virtual host"
},
"name": "/"
},
{
"metadata": {
"description": "Virtual host for ParkAPI"
},
"name": "park-api"
},
{
"metadata": {
"description": "Virtual host for OCPDB"
},
"name": "ocpdb"
}
]
}
5 changes: 5 additions & 0 deletions etc/rabbitmq/rabbitmq.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Just reload definitions if they are changed
definitions.skip_if_unchanged = true
# Point to definitions file
definitions.import_backend = local_filesystem
definitions.local.path = /etc/rabbitmq/definitions.json
Loading