blob: 8f0c2b4bc36d759fc8ee668d60a5342e64ba8023 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
use clap::Parser;
use std::path::PathBuf;
use tedge_config::DEFAULT_TEDGE_CONFIG_PATH;
mod error;
// on linux, we use systemd
#[cfg(target_os = "linux")]
mod systemd_watchdog;
#[cfg(target_os = "linux")]
use systemd_watchdog as watchdog;
// on non-linux, we do nothing for now
#[cfg(not(target_os = "linux"))]
mod dummy_watchdog;
#[cfg(not(target_os = "linux"))]
use dummy_watchdog as watchdog;
#[derive(Debug, clap::Parser)]
#[clap(
name = clap::crate_name!(),
version = clap::crate_version!(),
about = clap::crate_description!()
)]
pub struct WatchdogOpt {
/// Turn-on the debug log level.
///
/// If off only reports ERROR, WARN, and INFO
/// If on also reports DEBUG and TRACE
#[clap(long)]
pub debug: bool,
/// Start the watchdog from custom path
///
/// WARNING: This is mostly used in testing.
#[clap(long = "config-dir", default_value = DEFAULT_TEDGE_CONFIG_PATH)]
pub config_dir: PathBuf,
}
#[tokio::main]
async fn main() -> Result<(), anyhow::Error> {
let watchdog_opt = WatchdogOpt::parse();
tedge_utils::logging::initialise_tracing_subscriber(watchdog_opt.debug);
watchdog::start_watchdog(watchdog_opt.config_dir).await
}
|