refactor: remove Docker sleep
This commit is contained in:
+4
-11
@@ -52,9 +52,9 @@ async fn docker_init(
|
|||||||
docker_rx: Receiver<DockerMessage>,
|
docker_rx: Receiver<DockerMessage>,
|
||||||
docker_tx: Sender<DockerMessage>,
|
docker_tx: Sender<DockerMessage>,
|
||||||
gui_state: &Arc<Mutex<GuiState>>,
|
gui_state: &Arc<Mutex<GuiState>>,
|
||||||
host: Option<String>,
|
|
||||||
) {
|
) {
|
||||||
// let err = ||
|
let host = read_docker_host(&app_data.lock().args);
|
||||||
|
|
||||||
let connection = host.map_or_else(Docker::connect_with_socket_defaults, |host| {
|
let connection = host.map_or_else(Docker::connect_with_socket_defaults, |host| {
|
||||||
Docker::connect_with_socket(&host, 120, API_DEFAULT_VERSION)
|
Docker::connect_with_socket(&host, 120, API_DEFAULT_VERSION)
|
||||||
});
|
});
|
||||||
@@ -99,24 +99,17 @@ async fn main() {
|
|||||||
|
|
||||||
let args = CliArgs::new();
|
let args = CliArgs::new();
|
||||||
|
|
||||||
// If running via Docker image, need to sleep else program will just quit straight away, no real idea why
|
|
||||||
// So just sleep for small while
|
|
||||||
if args.in_container {
|
|
||||||
std::thread::sleep(std::time::Duration::from_millis(250));
|
|
||||||
}
|
|
||||||
let host = read_docker_host(&args);
|
|
||||||
|
|
||||||
let app_data = Arc::new(Mutex::new(AppData::default(args.clone())));
|
let app_data = Arc::new(Mutex::new(AppData::default(args.clone())));
|
||||||
let gui_state = Arc::new(Mutex::new(GuiState::default()));
|
let gui_state = Arc::new(Mutex::new(GuiState::default()));
|
||||||
let is_running = Arc::new(AtomicBool::new(true));
|
let is_running = Arc::new(AtomicBool::new(true));
|
||||||
let (docker_tx, docker_rx) = tokio::sync::mpsc::channel(32);
|
let (docker_tx, docker_rx) = tokio::sync::mpsc::channel(32);
|
||||||
|
|
||||||
docker_init(&app_data, docker_rx, docker_tx.clone(), &gui_state, host).await;
|
docker_init(&app_data, docker_rx, docker_tx.clone(), &gui_state).await;
|
||||||
|
|
||||||
if args.gui {
|
if args.gui {
|
||||||
let (input_tx, input_rx) = tokio::sync::mpsc::channel(32);
|
let (input_tx, input_rx) = tokio::sync::mpsc::channel(32);
|
||||||
handler_init(&app_data, &docker_tx, &gui_state, input_rx, &is_running);
|
handler_init(&app_data, &docker_tx, &gui_state, input_rx, &is_running);
|
||||||
Ui::create(app_data, gui_state, input_tx, is_running).await;
|
Ui::start(app_data, gui_state, input_tx, is_running).await;
|
||||||
} else {
|
} else {
|
||||||
info!("in debug mode\n");
|
info!("in debug mode\n");
|
||||||
let mut now = std::time::Instant::now();
|
let mut now = std::time::Instant::now();
|
||||||
|
|||||||
Reference in New Issue
Block a user