initial commit, empty rocket server

This commit is contained in:
Philippe Loctaux 2023-02-27 12:25:58 +01:00
commit 27d02a0d5c
11 changed files with 2980 additions and 0 deletions

10
crates/ezidam/Cargo.toml Normal file
View file

@ -0,0 +1,10 @@
[package]
name = "ezidam"
version = "0.1.0"
edition = "2021"
[dependencies]
rocket = "0.5.0-rc.2"
rocket_db_pools = { version = "0.1.0-rc.2", features = ["sqlx_sqlite"] }
rocket_dyn_templates = { version = "0.1.0-rc.2", features = ["tera"] }
infer = { version = "0.12.0", default-features = false }

15
crates/ezidam/justfile Executable file
View file

@ -0,0 +1,15 @@
#!/usr/bin/env just --justfile
cargo := "cargo"
# list recipes
default:
just --list
# start web server
start:
{{cargo}} run
# dev server
dev:
{{cargo}} watch -x "run"

21
crates/ezidam/readme.md Normal file
View file

@ -0,0 +1,21 @@
# ezidam
web server for ezidam
## initial setup
- install https://github.com/casey/just (it's like `make` but simpler)
- install https://github.com/watchexec/watchexec (to restart server when updating files)
## tools
- `just start` to start the web server in debug mode
- `just dev` to restart the web server when files are edited
## documentation
head over to [rocket.rs](https://rocket.rs) to read rocket's documentation
## configuration
to configure the web server, see `Rocket.toml` and the [reference](https://rocket.rs/v0.5-rc/guide/configuration/#rockettoml)

19
crates/ezidam/src/main.rs Normal file
View file

@ -0,0 +1,19 @@
mod shutdown;
// see for using rocket with main function https://github.com/intellij-rust/intellij-rust/issues/5975#issuecomment-920620289
#[rocket::main]
async fn main() -> std::result::Result<(), rocket::Error> {
// Build server
let rocket_builder = rocket::build();
// Shutdown
let rocket_builder = shutdown::shutdown(rocket_builder);
// Launch server
let _ = rocket_builder
.launch()
.await
.expect("Failed to launch server");
Ok(())
}

View file

@ -0,0 +1,10 @@
use rocket::fairing::AdHoc;
use rocket::{Build, Rocket};
pub fn shutdown(rocket_builder: Rocket<Build>) -> Rocket<Build> {
rocket_builder.attach(AdHoc::on_shutdown("Shutdown", |_| {
Box::pin(async move {
println!("Shutdown has been requested");
})
}))
}