mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-05-20 23:10:37 +00:00
add path for FileWatch snafu
Signed-off-by: tison <wander4096@gmail.com>
This commit is contained in:
@@ -64,8 +64,9 @@ pub enum Error {
|
||||
username: String,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to initialize a watcher for file"))]
|
||||
#[snafu(display("Failed to initialize a watcher for file {}", path))]
|
||||
FileWatch {
|
||||
path: Option<String>,
|
||||
#[snafu(source)]
|
||||
error: notify::Error,
|
||||
},
|
||||
|
||||
@@ -43,13 +43,15 @@ impl WatchFileUserProvider {
|
||||
};
|
||||
|
||||
let (tx, rx) = channel::<DebounceEventResult>();
|
||||
|
||||
let mut debouncer =
|
||||
new_debouncer(Duration::from_secs(1), None, tx).context(FileWatchSnafu)?;
|
||||
let mut debouncer = new_debouncer(Duration::from_secs(1), None, tx)
|
||||
.context(FileWatchSnafu { path: None })?;
|
||||
debouncer
|
||||
.watcher()
|
||||
.watch(Path::new(filepath), RecursiveMode::NonRecursive)
|
||||
.context(FileWatchSnafu)?;
|
||||
.context(FileWatchSnafu {
|
||||
path: Some(filepath),
|
||||
})?;
|
||||
|
||||
let filepath = filepath.to_string();
|
||||
std::thread::spawn(move || {
|
||||
let _hold = debouncer;
|
||||
|
||||
@@ -449,8 +449,9 @@ pub enum Error {
|
||||
))]
|
||||
UnexpectedPhysicalTable { location: Location },
|
||||
|
||||
#[snafu(display("Failed to initialize a watcher for file"))]
|
||||
#[snafu(display("Failed to initialize a watcher for file {}", path))]
|
||||
FileWatch {
|
||||
path: Option<String>,
|
||||
#[snafu(source)]
|
||||
error: notify::Error,
|
||||
},
|
||||
|
||||
@@ -200,21 +200,21 @@ pub fn maybe_watch_tls_config(tls_server_config: Arc<ReloadableTlsServerConfig>)
|
||||
let tls_server_config_for_watcher = tls_server_config.clone();
|
||||
|
||||
let (tx, rx) = channel::<notify::Result<notify::Event>>();
|
||||
let mut watcher = notify::recommended_watcher(tx).context(FileWatchSnafu)?;
|
||||
let mut watcher = notify::recommended_watcher(tx).context(FileWatchSnafu { path: None })?;
|
||||
|
||||
let cert_path = tls_server_config.get_tls_option().cert_path();
|
||||
watcher
|
||||
.watch(
|
||||
tls_server_config.get_tls_option().cert_path(),
|
||||
RecursiveMode::NonRecursive,
|
||||
)
|
||||
.context(FileWatchSnafu)?;
|
||||
.watch(cert_path, RecursiveMode::NonRecursive)
|
||||
.context(FileWatchSnafu {
|
||||
path: Some(cert_path),
|
||||
})?;
|
||||
|
||||
let key_path = tls_server_config.get_tls_option().key_path();
|
||||
watcher
|
||||
.watch(
|
||||
tls_server_config.get_tls_option().key_path(),
|
||||
RecursiveMode::NonRecursive,
|
||||
)
|
||||
.context(FileWatchSnafu)?;
|
||||
.watch(key_path, RecursiveMode::NonRecursive)
|
||||
.context(FileWatchSnafu {
|
||||
path: Some(key_path),
|
||||
})?;
|
||||
|
||||
std::thread::spawn(move || {
|
||||
let _watcher = watcher;
|
||||
|
||||
Reference in New Issue
Block a user