🐛 bug: the GUI can now restart `ptth_server` properly
parent
0d3b402050
commit
41d5b896a9
|
@ -1,34 +1,21 @@
|
|||
use fltk::{app, button::Button, frame::Frame, prelude::*, window::Window};
|
||||
|
||||
async fn run_ptth_server () -> Result <(), anyhow::Error>
|
||||
{
|
||||
let config_file = ptth_server::ConfigFile {
|
||||
name: "ptth_server".into (),
|
||||
api_key: ptth_core::gen_key (),
|
||||
relay_url: "http://127.0.0.1:4000/7ZSFUKGV".into (),
|
||||
file_server_root: Some (".".into ()),
|
||||
throttle_upload: false,
|
||||
use std::{
|
||||
sync::Arc,
|
||||
};
|
||||
|
||||
tracing::debug! ("Running PTTH server task");
|
||||
use fltk::{
|
||||
app,
|
||||
button::Button,
|
||||
frame::Frame,
|
||||
prelude::*,
|
||||
window::Window
|
||||
};
|
||||
|
||||
ptth_server::run_server (
|
||||
config_file,
|
||||
ptth_core::graceful_shutdown::init (),
|
||||
None,
|
||||
None
|
||||
).await?;
|
||||
|
||||
tracing::debug! ("Ended PTTH server task");
|
||||
|
||||
Ok (())
|
||||
}
|
||||
use tokio::{
|
||||
sync::Mutex,
|
||||
};
|
||||
|
||||
fn main ()
|
||||
{
|
||||
use std::sync::Arc;
|
||||
use tokio::sync::Mutex;
|
||||
|
||||
let rt = tokio::runtime::Runtime::new ().unwrap ();
|
||||
let rt_handle = rt.handle ();
|
||||
|
||||
|
@ -39,6 +26,8 @@ fn main ()
|
|||
|
||||
let ptth_server_task = Arc::new (Mutex::new (None));
|
||||
|
||||
let shutdown_rx = ptth_core::graceful_shutdown::init ();
|
||||
|
||||
let app = app::App::default();
|
||||
let mut wind = Window::new(100, 100, 400, 300, "Hello from rust");
|
||||
let frame = Frame::new(0, 0, 400, 200, stopped_msg);
|
||||
|
@ -56,8 +45,24 @@ fn main ()
|
|||
rt_handle.block_on (async {
|
||||
let mut task = ptth_server_task.lock ().await;
|
||||
task.replace (Some (tokio::spawn (async {
|
||||
if let Err (e) = run_ptth_server ().await {
|
||||
tracing::error! ("{}", e);
|
||||
let config_file = ptth_server::ConfigFile {
|
||||
name: "ptth_server".into (),
|
||||
api_key: ptth_core::gen_key (),
|
||||
relay_url: "http://127.0.0.1:4000/7ZSFUKGV".into (),
|
||||
file_server_root: Some (".".into ()),
|
||||
throttle_upload: false,
|
||||
};
|
||||
|
||||
let (_tx, shutdown_rx) = tokio::sync::oneshot::channel ();
|
||||
|
||||
if let Err (e) = ptth_server::run_server (
|
||||
config_file,
|
||||
shutdown_rx,
|
||||
None,
|
||||
None
|
||||
).await
|
||||
{
|
||||
tracing::error! ("ptth_server crashed: {}", e);
|
||||
}
|
||||
})));
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue