* Add wasm server_manager and ownership guard Introduce a new wasm server_manager module that implements WasmServerOwnershipGuard to manage per-workspace lock files, PID/port ownership, and safe replacement of stale or live servers. Integrate the guard into compile::run by preparing and activating the guard before starting the HTTP server; start_wasm_server now accepts the guard, returns a Result, checks bind success, activates the guard, and propagates thread join errors. The server manager includes platform-specific PID handling, port-probing, lock read/write/remove helpers, and unit tests exercising startup scenarios and lock lifecycle. Also add mod declaration and apply minor formatting/refactor cleanups across compile.rs (error formatting, whitespace, and logging improvements). * Add startup mutex and port occupant diagnostics Rename server_manager into top-level module and add startup mutex handling and improved diagnostics. Introduces atomic lock writes (write_file_atomically), a StartupMutexGuard with configurable timeouts/polling, and logic to detect/recover stale startup locks to prevent concurrent wasm run startups. Extends ServerManagerProbes with describe_port_occupant and implements platform-specific detection (lsof on Unix, netstat/tasklist on Windows) to provide clearer errors when ports are occupied. Updates imports (main.rs, compile.rs, mod.rs) and adds unit tests covering startup lock behavior and unknown-occupant error text. * Improve hot-reload logging and delivery Add clearer logging and error handling for wasm hot-reload events. Introduces hot_reload_display_name to extract a user-friendly file name, logs when a hotreload is detected, and checks tx.send result to avoid panics when the watcher channel is closed. broadcast_hot_reload_event now logs whether events were skipped (no /$watch clients) or sent and includes the delivered client count with proper pluralization. * Check lock PID owns port and add startup timestamp Require that a lock's PID both be alive and actually own the server port to be considered a live lock (classify_lock_state now takes listen_addr). Add parsing of a started_at timestamp in startup locks and use now_unix_millis to age out stale startup locks even if the PID is alive. Extend ServerManagerProbes with now_unix_millis and pid_owns_port, implement port_occupant_info and PortOccupant to centralize occupant detection/refinement for unix and windows, and refactor describe_port_occupant to use it. Update tests and MockProbes to exercise PID ownership checks and startup-lock aging; add tests for PID reuse (treated as stale if it doesn't own the port) and for startup lock aging. * Hot reload: dedupe sites, add logging Avoid duplicate ScriptMod sites during hot reload and improve diagnostics. collect_compiled_sites_for_file now tracks seen ScriptModKey values to prevent pushing duplicates. handle_cx_live_edit counts processed files and logs how many overrides were applied and from how many changed files. forward_hot_reload_fs_event logs each detected file and reports if the watcher channel is closed. Minor import cleanup and a helper hot_reload_display_name were added for nicer log output. * shared core for reload * Warn and fallback to unminified JS on write error When writing the minified JS file fails, log a warning and fall back to copying the original JS file instead of returning an error. This avoids failing the build on IO/write errors (e.g. permissions or disk issues) while preserving the previous behavior of using the unminified copy when reading fails. No change to successful minification path.
9 lines
282 B
TOML
9 lines
282 B
TOML
[package]
|
|
name = "makepad-live-reload-core"
|
|
version = "0.1.0"
|
|
edition = "2021"
|
|
description = "Shared live reload watcher core for native and wasm flows"
|
|
license = "MIT OR Apache-2.0"
|
|
|
|
[dependencies]
|
|
makepad-filesystem-watcher = { path = "../filesystem_watcher", version = "0.1.0" }
|