Deamon + minor update
This commit is contained in:
1948
Cargo.lock
generated
Normal file
1948
Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
48
src/main.rs
48
src/main.rs
@@ -218,34 +218,34 @@ async fn main() {
|
|||||||
let daemonize = Daemonize::new()
|
let daemonize = Daemonize::new()
|
||||||
.pid_file("/tmp/test.pid") // Every method except `new` and `start`
|
.pid_file("/tmp/test.pid") // Every method except `new` and `start`
|
||||||
.chown_pid_file(true) // is optional, see `Daemonize` documentation
|
.chown_pid_file(true) // is optional, see `Daemonize` documentation
|
||||||
.working_directory("/tmp") // for default behaviour.
|
.working_directory("/home/aindustries/vote-rllhc/") // for default behaviour.
|
||||||
.stdout(stdout) // Redirect stdout to `/tmp/daemon.out`.
|
.stdout(stdout) // Redirect stdout to `/tmp/daemon.out`.
|
||||||
.stderr(stderr); // Redirect stderr to `/tmp/daemon.err`.
|
.stderr(stderr); // Redirect stderr to `/tmp/daemon.err`.
|
||||||
|
|
||||||
match daemonize.start() {
|
match daemonize.start() {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
let _ = dotenv();
|
let _ = dotenv();
|
||||||
let db_adrr = find_in_vars("DATABASE_ADRR");
|
let db_adrr = find_in_vars("DATABASE_ADRR");
|
||||||
let db_pool = Arc::new(Mutex::new(SqlitePool::connect(&db_adrr).await.unwrap()));
|
let db_pool = Arc::new(Mutex::new(SqlitePool::connect(&db_adrr).await.unwrap()));
|
||||||
let bind_adrr: SocketAddr = SocketAddr::from_str(find_in_vars("BIND_ADRR").as_str()).expect("Could not parse bind address");
|
let bind_adrr: SocketAddr = SocketAddr::from_str(find_in_vars("BIND_ADRR").as_str()).expect("Could not parse bind address");
|
||||||
let listener = TcpListener::bind(bind_adrr).await.expect("Could not bind to address.");
|
let listener = TcpListener::bind(bind_adrr).await.expect("Could not bind to address.");
|
||||||
loop {
|
loop {
|
||||||
let (tcp, _) = listener.accept().await.expect("Could not accept stream");
|
let (tcp, _) = listener.accept().await.expect("Could not accept stream");
|
||||||
let io = TokioIo::new(tcp);
|
let io = TokioIo::new(tcp);
|
||||||
let db = db_pool.clone();
|
let db = db_pool.clone();
|
||||||
let service = service_fn(move |req| {
|
let service = service_fn(move |req| {
|
||||||
service(req, db.clone())
|
service(req, db.clone())
|
||||||
});
|
});
|
||||||
tokio::task::spawn(async move {
|
tokio::task::spawn(async move {
|
||||||
if let Err(err) = http1::Builder::new()
|
if let Err(err) = http1::Builder::new()
|
||||||
.timer(TokioTimer::new())
|
.timer(TokioTimer::new())
|
||||||
.serve_connection(io, service).await
|
.serve_connection(io, service).await
|
||||||
{
|
{
|
||||||
println!("Failed to serve connection: {:?}", err);
|
println!("Failed to serve connection: {:?}", err);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}},
|
}
|
||||||
|
},
|
||||||
Err(e) => eprintln!("Error, {}", e),
|
Err(e) => eprintln!("Error, {}", e),
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,9 +29,9 @@ body {
|
|||||||
margin:auto;
|
margin:auto;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
width: 100%;
|
width: 90%;
|
||||||
max-width: 500px;
|
max-width: 500px;
|
||||||
height: calc(100vh - 60px);
|
height: calc(100dvh - 60px);
|
||||||
}
|
}
|
||||||
|
|
||||||
.app > h2 {
|
.app > h2 {
|
||||||
@@ -94,4 +94,4 @@ body {
|
|||||||
|
|
||||||
.confirm > h3 {
|
.confirm > h3 {
|
||||||
color: white;
|
color: white;
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
vote.db-shm
BIN
vote.db-shm
Binary file not shown.
BIN
vote.db-wal
BIN
vote.db-wal
Binary file not shown.
Reference in New Issue
Block a user