MCPcopy Create free account
hub / github.com/Licoy/fetch-github-hosts / start_server

Function start_server

src-tauri/src/commands.rs:55–77  ·  view source on GitHub ↗
(
    app: AppHandle,
    port: u16,
    interval: u32,
    state: State<'_, Mutex<ServerState>>,
)

Source from the content-addressed store, hash-verified

53
54#[tauri::command]
55pub async fn start_server(
56 app: AppHandle,
57 port: u16,
58 interval: u32,
59 state: State<'_, Mutex<ServerState>>,
60) -> Result<(), String> {
61 // Stop existing server if running
62 {
63 let mut s = state.lock().map_err(|e| e.to_string())?;
64 if let Some(tx) = s.stop_tx.take() {
65 let _ = tx.send(());
66 }
67 }
68
69 let (tx, rx) = oneshot::channel();
70 {
71 let mut s = state.lock().map_err(|e| e.to_string())?;
72 s.stop_tx = Some(tx);
73 }
74
75 tokio::spawn(services::start_server_task(app, port, interval, rx));
76 Ok(())
77}
78
79#[tauri::command]
80pub async fn stop_server(state: State<'_, Mutex<ServerState>>) -> Result<(), String> {

Callers

nothing calls this directly

Calls 1

start_server_taskFunction · 0.85

Tested by

no test coverage detected