This crate contains an OpenADR VTN implementation.
The following contains information specific to the VTN application, i.e., the server. If you are interested in information about the whole project, please visit the project level Readme.
Your machine needs a recent version of Rust installed.
Please refer to the official installation website for the setup.
To apply the Database migrations, you also need the sqlx-cli installed.
Simply run cargo install sqlx-cli
.
All the following commands are executed in the root directory of the Git repository.
First, start up a postgres database. For example, using docker compose:
docker compose up -d db
Run the migrations:
cargo sqlx migrate run
Running the VTN using cargo:
RUST_LOG=trace cargo run --bin openleadr-vtn
Running the VTN using docker-compose:
docker compose up -d
This workspace uses SQLX macro to type check SQL statements. In order to build the crate without a running SQL server (such as in the docker), SQLX must be run in offline mode. In this mode type checking is done via a cached variant of the DB (the .sqlx directory). For this to work as intended, each time a change is made to SQL schemas or queries, please run
cargo sqlx prepare --workspace
This will update the cached SQL in the .sqlx
directory which should be committed to GitHub.
To expedite the slow cargo release builds, the Dockerfile uses a multi-stage build. If changes have been made and are not being reflected in the binary running inside docker, try
docker compose up --force-recreate --build --no-deps vtn
This will force a rebuild
Running the client
cargo run --bin openleadr