pub fn spawn_node_sidecar(app: &AppHandle, sidecar_name: &str) -> Result<()>Expand description
Spawns a Node.js sidecar with DNS override configured to use the local Hickory DNS server.
This function:
- Creates the app data directory if it doesn’t exist
- Writes the DNS override JavaScript file to the app data directory
- Configures the sidecar process with NODE_OPTIONS to require the DNS override script
- Sets the LAND_DNS_SERVER environment variable with the local DNS server address
- Spawns the sidecar process
§Parameters
app- The Tauri app handle, used to access the app data directory and shellsidecar_name- The name of the sidecar executable to spawn
§Returns
Returns Ok(()) if the sidecar was spawned successfully, or an error if:
- The app data directory couldn’t be created or accessed
- The DNS override file couldn’t be written
- The sidecar couldn’t be found or spawned
§Example
use tauri::Manager;
use SideCar::Spawn::spawn_node_sidecar;
#[tauri::command]
fn launch_sidecar(app:tauri::AppHandle) -> Result<(), String> {
spawn_node_sidecar(&app, "my-sidecar").map_err(|e| e.to_string())?;
Ok(())
}