Add rocket.toml and peach-dyndns-server.service

This commit is contained in:
notplants 2021-05-19 11:55:33 +02:00
parent cb604de46c
commit 5b7112645b
5 changed files with 36 additions and 6 deletions

2
Cargo.lock generated
View File

@ -1299,7 +1299,7 @@ dependencies = [
]
[[package]]
name = "peach-dyndns-host"
name = "peach-dyndns-server"
version = "0.1.0"
dependencies = [
"clap-log-flag",

View File

@ -1,5 +1,5 @@
[package]
name = "peach-dyndns-host"
name = "peach-dyndns-server"
version = "0.1.0"
authors = ["Michael Williams <michael.williams@enspiral.com>", "Max Fowler <notplants@mfowler.info>"]
edition = "2018"
@ -24,6 +24,13 @@ dotenv = "0.15.0"
tera = "1"
regex = "1"
[[bin]]
name = "main"
path = "src/main.rs"
[package.metadata.deb]
depends = "$auto"
extended-description = """\
peach-dyndns is an http API to create dynamic-dns configurations for bind9."""
maintainer-scripts="debian"
systemd-units = { unit-name = "peach-dyndns-server" }
assets = [
["target/release/peach-dyndns-server", "usr/bin/", "755"],
]

3
Rocket.toml Normal file
View File

@ -0,0 +1,3 @@
[default]
template_dir = "templates/"
port = 3001

13
debian/peach-dyndns-server.service vendored Normal file
View File

@ -0,0 +1,13 @@
[Unit]
Description=An http API to create dynamic-dns configurations for bind9.
[Service]
Type=simple
User=peach-dyndns
Group=bind
Environment="RUST_LOG=info"
ExecStart=/usr/bin/peach-dyndns-server
Restart=always
[Install]
WantedBy=multi-user.target

View File

@ -4,6 +4,8 @@
extern crate rocket;
use crate::routes::{index, register_domain, check_available};
use rocket::Config;
use rocket::figment::{Figment, Profile, providers::{Format, Toml, Serialized, Env}};
mod cli;
mod routes;
@ -15,7 +17,12 @@ mod generate_zone;
async fn main() {
let _args = cli::args().expect("error parsing args");
let rocket_result = rocket::build()
// the following config says to use all default rocket configs
// and then override them with any configs specified in Rocket.toml
let config = Figment::from(rocket::Config::default())
.merge(Toml::file("Rocket.toml").nested());
let rocket_result = rocket::custom(config)
.mount("/", routes![index, register_domain, check_available])
.launch()
.await;