Vote + Results done
This commit is contained in:
@@ -21,3 +21,4 @@ futures = "0.3.30"
|
||||
chrono = { version = "0.4.38", features = ["alloc"]}
|
||||
futures-util = "0.3.30"
|
||||
h2 = "0.4.6"
|
||||
daemonize = "0.5.0"
|
||||
|
||||
16
src/main.rs
16
src/main.rs
@@ -23,6 +23,7 @@ use std::net::SocketAddr;
|
||||
use std::str::FromStr;
|
||||
use std::sync::{Arc, Mutex};
|
||||
use std::time::SystemTime;
|
||||
use daemonize::Daemonize;
|
||||
use tokio::net::TcpListener;
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
@@ -211,6 +212,18 @@ fn find_in_vars(pattern: &str) -> String {
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
let stdout = File::create("/tmp/daemon.out").unwrap();
|
||||
let stderr = File::create("/tmp/daemon.err").unwrap();
|
||||
|
||||
let daemonize = Daemonize::new()
|
||||
.pid_file("/tmp/test.pid") // Every method except `new` and `start`
|
||||
.chown_pid_file(true) // is optional, see `Daemonize` documentation
|
||||
.working_directory("/tmp") // for default behaviour.
|
||||
.stdout(stdout) // Redirect stdout to `/tmp/daemon.out`.
|
||||
.stderr(stderr); // Redirect stderr to `/tmp/daemon.err`.
|
||||
|
||||
match daemonize.start() {
|
||||
Ok(_) => {
|
||||
let _ = dotenv();
|
||||
let db_adrr = find_in_vars("DATABASE_ADRR");
|
||||
let db_pool = Arc::new(Mutex::new(SqlitePool::connect(&db_adrr).await.unwrap()));
|
||||
@@ -231,5 +244,8 @@ async fn main() {
|
||||
println!("Failed to serve connection: {:?}", err);
|
||||
}
|
||||
});
|
||||
}},
|
||||
Err(e) => eprintln!("Error, {}", e),
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user