#![cfg_attr(docsrs, feature(doc_cfg))]

use std::{env, future::Future};

mod run;

pub use run::{Exit, Run};

/// Worker 模式环境变量名 / Worker mode environment variable name
const SYSTEMD_RELOAD_WORKER: &str = "SYSTEMD_RELOAD_WORKER";

/// 用于判断当前是否处于 Worker 模式
/// 防止无限递归启动
pub fn is_worker() -> bool {
  env::var(SYSTEMD_RELOAD_WORKER).is_ok()
}

/// 便捷函数：直接运行进程管理器 / Convenience function: run process manager directly
pub fn run() -> impl Future<Output = ()> {
  Run::new().run()
}
