The project is written in Rust. It is
written in Rust Edition 2018
, using the latest stable release.
- We use Cargo for the package manager.
- We use rustup for managing the tool chain.
- We use mdBook for API endpoint documentation.
- We use rustfmt for formatting Rust source code.
The actual Rust project is under vrme_server
, so start by changing the working
directory into vrme_server
:
cd vrme_server
All of the instructions below assume that you are under the vrme_server
directory already.
If you want to generate and render code documentation for vrme_server
, run
cargo doc
And the docs will be generated under target/doc
.
-
If you wish to open the documentation in the browser directly, run instead (the browser executable pointed to by
$BROWSER
):cargo doc --open
-
If you don't want to generate docs for dependency crates, specify the
--no-deps
flag tocargo doc
cargo doc --no-deps --open
Available at VRME-API-Documentation.
To specify the logging level, provide LOG
with one of:
Verbosity | LOG= |
---|---|
Most verbose | TRACE |
DEBUG |
|
INFO |
|
WARN |
|
Least verbose | ERROR |
LOG=INFO
is the default logging level.
Example log level setting:
LOG=WARN RUN_MODE=production cargo run --release
Run the application in either development mode or production mode by specifying
RUN_MODE
:
-
Production mode:
RUN_MODE=production cargo run --release
The
--release
flag passed tocargo
enables-O3
optimization by default which is suitable for production mode, but erases useful debugging information for development. -
Development mode:
RUN_MODE=development cargo run
The server will:
-
Read from a base (shared) configuration file:
# Copy example default configuration cp config/default.example.toml config/default.toml
-
Read from a
RUN_MODE
-dependent configuration file.Change
$RUN_MODE
below to eitherproduction
ordevelopment
.# Copy example $RUN_MODE-dependent configuration cp config/$RUN_MODE.example.toml config/$RUN_MODE.toml
-
Read from environment variables that have the same key name as the ones in the configuration file. The environment variables need to be prefixed by
APP_
. When the configuration is nested, such asserver.hostname
, use the separator__
to replace the dot as the name of the environment variable.Example:
server.hostname
is overriden byAPP_SERVER__HOSTNAME
.# Override `server.hostname` APP_SERVER__HOSTNAME=127.0.0.1 \ RUN_MODE=development \ cargo run
Environment variables take precedence over RUN_MODE
-specific configuration
files, which in turn take precedence over the default shared configuration
file.
See the src/settings
module for the most accurate configuration options.