Skip to content

stadtnavi/delay-prediction-service

Repository files navigation

delay-prediction-service

Predict delays for Herrenberg buses. Part of Stadtnavi Herrenberg.

CI status tests ISC-licensed

documentation

deploying to production

A Docker image is available as stadtnavi/delay-prediction-service.

Note: Depending on your setup, you may also need to configure access to PostgreSQL using the PG* environment variables.

building

scripts/build.sh is designed to allow continuous deployments. Given the name and URL of a GTFS feed, it will generate all necessary data for delay-prediction-service to work.

The following is an example with the VVS feed, cleaned up and served by gtfs.mfdz.de.

docker run --rm -it \
    -v /var/delay-prediction-service-data:/app/data \
    -e TIMEZONE -e LOCALE \
    -e PGHOST -e PGUSER -e PGPASSWORD \
    -e GTFS_NAME=vss -e GTFS_URL='https://gtfs.mfdz.de/VVS.filtered.gtfs.zip'
    stadtnavi/delay-prediction-service \
    ./scripts/build.sh

running

export TIMEZONE=Europe/Berlin
export LOCALE=de-DE

Configure access to Thingsboard, the PostgreSQL database and the MQTT broker using environment variables:

export THINGSBOARD_URL='https://thingsboard.cloud'
export THINGSBOARD_USER=''
export THINGSBOARD_PASSWORD=''
export THINGSBOARD_DEVICE_GROUP='' # ID of the Thingsboard device group
export PGUSER=postgres
#
export MQTT_URI='mqtt://localhost:1883'

Now run the service:

docker run --rm -it \
    -v /var/delay-prediction-service-data:/app/data \
    -p 3000:3000 \
    -e TIMEZONE -e LOCALE \
    -e THINGSBOARD_URL -e THINGSBOARD_USER -e THINGSBOARD_PASSWORD -e THINGSBOARD_DEVICE_GROUP \
    -e MQTT_URI \
    -e PGHOST -e PGUSER -e PGPASSWORD
    stadtnavi/delay-prediction-service

running manually

You can also run delay-prediction-service manually.

# clone repo
git clone https://github.com/stadtnavi/delay-prediction-service.git
cd delay-prediction-service
# install dependencies
npm install

Note: The environment variables mentioned above must be set.

# build step
env GTFS_NAME=vss -e GTFS_URL='https://gtfs.mfdz.de/VVS.filtered.gtfs.zip' ./scripts/build.sh

# run step
node index.js