8000 Add backend server check every 60 seconds by timmo001 · Pull Request #2922 · timmo001/system-bridge · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add backend server check every 60 seconds #2922

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 17 additions & 10 deletions src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
use reqwest::Client;
use serde::{Deserialize, Serialize};
use std::error::Error;
use std::path::Path;
use std::process::Command;
use std::time::Duration;
use std::{error::Error, thread};
use tauri::{
menu::{MenuBuilder, MenuItemBuilder, PredefinedMenuItem, SubmenuBuilder},
tray::ClickType,
Expand All @@ -15,6 +15,8 @@ use tauri_plugin_autostart::MacosLauncher;
use tauri_plugin_autostart::ManagerExt;
use tauri_plugin_clipboard_manager::ClipboardExt;
use tauri_plugin_shell::ShellExt;
use tokio::runtime::Runtime;
use tokio::time::interval;

#[derive(Serialize, Deserialize)]
struct APIBaseResponse {
Expand Down Expand Up @@ -426,16 +428,21 @@ async fn main() {
_ => (),
});

// TODO: Check backend server every 30 seconds
// tauri::async_runtime::spawn(async {
// let mut interval = interval(Duration::from_secs(30));
// loop {
// println!("Waiting for 30 seconds before checking the backend server again");
// interval.tick().await;
// Check backend server is running every 30 seconds
let handle = thread::spawn(|| {
let rt = Runtime::new().unwrap();
rt.block_on(async {
let mut interval: tokio::time::Interval = interval(Duration::from_secs(60));
loop {
println!("Waiting for 60 seconds before checking the backend server again");
interval.tick().await;

// setup_app().await;
// }
// });
setup_app().await.unwrap();
}
});
});

// handle.join().unwrap();

Ok(())
})
Expand Down
0