This commit is contained in:
lda
2026-04-13 00:35:42 +07:00 Unverified
parent 1bbbe1615e
commit c4d7c51f7e
4 changed files with 24 additions and 19 deletions
+9 -10
View File
@@ -35,9 +35,7 @@ async fn main() -> Result<()> {
} }
} }
} }
Command::InitConfig(args) => { Command::InitConfig(args) => init_config(args)?,
init_config(args)?
}
Command::Reload(args) => { Command::Reload(args) => {
::tracing::info!(pid_file = %args.pid_file.display(), "wakey-agent command: reload"); ::tracing::info!(pid_file = %args.pid_file.display(), "wakey-agent command: reload");
serve::reload_daemon(&args.pid_file)? serve::reload_daemon(&args.pid_file)?
@@ -52,13 +50,14 @@ fn init_config(args: InitConfigArgs) -> Result<()> {
anyhow::bail!("--stdout cannot be used with --config"); anyhow::bail!("--stdout cannot be used with --config");
} }
if let Some(config) = &args.config { if let Some(config) = &args.config
if config.exists() && !args.force { && config.exists()
anyhow::bail!( && !args.force
"config {} already exists; re-run with --force to overwrite", {
config.display() anyhow::bail!(
); "config {} already exists; re-run with --force to overwrite",
} config.display()
);
} }
let cfg = config::AgentConfig { let cfg = config::AgentConfig {
+8 -7
View File
@@ -11,13 +11,14 @@ pub fn write_init_config(args: &InitConfigArgs) -> Result<Option<PathBuf>> {
anyhow::bail!("--stdout cannot be used with --config-file"); anyhow::bail!("--stdout cannot be used with --config-file");
} }
if let Some(config_file) = &args.config_file { if let Some(config_file) = &args.config_file
if config_file.exists() && !args.force { && config_file.exists()
anyhow::bail!( && !args.force
"config {} already exists; re-run with --force to overwrite", {
config_file.display() anyhow::bail!(
); "config {} already exists; re-run with --force to overwrite",
} config_file.display()
);
} }
let bind = args.bind.unwrap_or_else(|| { let bind = args.bind.unwrap_or_else(|| {
+3 -1
View File
@@ -190,7 +190,9 @@ fn resolve_admin_public_url(
) -> Result<Option<String>> { ) -> Result<Option<String>> {
match (mode.live, mode.offline) { match (mode.live, mode.offline) {
(true, false) => config_public_url (true, false) => config_public_url
.ok_or_else(|| anyhow::anyhow!("--live requires --public-url or a configured public_url")) .ok_or_else(|| {
anyhow::anyhow!("--live requires --public-url or a configured public_url")
})
.map(Some), .map(Some),
(false, true) => Ok(None), (false, true) => Ok(None),
_ => Ok(config_public_url), _ => Ok(config_public_url),
+4 -1
View File
@@ -32,7 +32,10 @@ async fn main() -> Result<()> {
Command::InitConfig(args) => { Command::InitConfig(args) => {
if let Some(path) = config::write_init_config(&args)? { if let Some(path) = config::write_init_config(&args)? {
println!("config={}", path.display()); println!("config={}", path.display());
println!("next=wakey-control-plane serve --config-file {}", path.display()); println!(
"next=wakey-control-plane serve --config-file {}",
path.display()
);
} }
Ok(()) Ok(())
} }