Skip to main content

watch_config

Function watch_config 

Source
pub async fn watch_config(state: Arc<SharedState>, config_path: PathBuf)
Expand description

Watches config files for changes and triggers hot-reload.

Spawns a dedicated OS thread running a notify watcher on the config file’s parent directory (recursively), forwarding modify/create events over a channel to this async loop. Events are debounced: after the first event the loop waits 500ms and drains any further events, so a burst of filesystem notifications (as editors typically produce) results in a single SharedState::reload_from_disk call. Reload failures are logged and leave the previously loaded configuration in place. Runs until the event channel closes; intended to be spawned as a long-lived task.