GitXplorerGitXplorer
a

open-taffeta

public
8 stars
4 forks
12 issues

Commits

List of commits on branch develop.
Unverified
ad6ee17e15ba0620adcec00105162ce0bf1427b4

disable a test, remove the warning

aapiraino committed 6 years ago
Unverified
cf08bc8fa5d221b566e82d8be4b97585243e41ce

Merge branch 'add-logging-facility' into develop

aapiraino committed 6 years ago
Unverified
86c491e228202ca850a563f6da158484510788e0

increasing the carbon footprint for nothing

aapiraino committed 6 years ago
Unverified
3923a33a0184ba0b68ec987822c4282ee96f134c

logging docs, set logging in deployment, cleanup

aapiraino committed 6 years ago
Unverified
456a25f015fb3f6dbfc33f262468843f1a9f7f0c

replace prints with stdout logging

aapiraino committed 6 years ago
Unverified
54d789bafec73f5ba66ae250bbd682f20a485e31

explain logging

aapiraino committed 6 years ago

README

The README file for this repository.

open-taffeta Build Status

Raspberry Pi-hosted website controlling access to a building

The mobile App interfacing to this backend is hosted here.

Rust installation

Install Rust

curl https://sh.rustup.rs -sSf | sh

Select the custom setup and choose the nightly compiler (Rocket does not yet run on stable, see Caveats).

If you have already Rust installed (stable or beta), simply install the additional toolchain:

$ rustup toolchain install nightly
$ rustup override set nightly

Install sources (in case you want to use linting tools like racer or RLS):

rustup component add rust-src

Additional libraries

Install libssl-dev to compile OpenSSL, libmysqlclient-dev to install diesel-cli.

Additional tooling for this project

Install cargo-edit (to get cargo add superpowers) and cargo-deb.

Install the ORM (Diesel) cli:

cargo install diesel_cli --no-default-features --features sqlite

Performs DB setup and migrations

$ sh env.sh <ROCKET_ENV> (dev, staging, production)
$ diesel setup
$ diesel migration generate create_users

Write the SQL to create migrations (up.sql and down.sql)

Run both migrations to check if they are ok:

diesel migration run

Running tests

Integration tests need the server running, so first launch cargo run in a shell and cargo test --all in another one. Run one single test with ex. cargo test test_list_users or to run an entire directory of tests with ex. cargo test --test test_users.

To run test sequencially instead of parallelized (by default), use:

RUST_TEST_THREADS=1 cargo test

or

cargo test -- --test-threads=1

Running the server

cargo run

with different logging enabled:

Logging levels:

Application and every (!) library (don't do this): RUST_LOG=debug cargo run

Whole Open-Taffeta application: RUST_LOG=open_taffeta_lib=debug cargo run

Whole Open-Taffeta and Rocket INFO: RUST_LOG=rocket::rocket=INFO,open_taffeta_lib=debug cargo run

DB module only: RUST_LOG=open_taffeta_lib::db=debug cargo run

Deployment instructions

Install Rust nightly

$ curl https://sh.rustup.rs -sSf | sh
$ rustup toolchain install nightly
$ rustup override set nightly
$ cargo install diesel_cli

Get latest release package

  • https://github.com/apiraino/open-taffeta/releases/
  • dpkg -i open-taffeta_x.y.z_amd64.deb
  • Configure .env_dev with buzzer endpoint
  • $ diesel setup
  • sudo systemctl start open-taffeta

Testing the endpoint

curl "http://localhost:8000" -H "Content-Type: application/json"

The response should look like this JSON:

[{
    "email": "apiraino@users.noreply.github.com",
    "id": 1,
    "password": "123456",
    "username": "apiraino"
}, {
    "email": "kkom@users.noreply.github.com",
    "id": 2,
    "password": "654321",
    "username": "kkom"
}]

As a Docker container

  • Dockerfile: recipe to build the image

  • docker-build.sh: script to rebuild the image (~1.7gb currently, working on making it thinner)

  • docker-run.sh: script to tun locally the container for test

  • docker-compose -f docker-compose.yml up: raise the container using docker compose (adviced)

Endpoints

See Wiki

Caveats

Keeping track of past and current issues, not related to the codebase but to external Rust tooling.

See Wiki.