Skip to content

Commit 9029de1

Browse files
felipecslclaude
andauthored
fix: Use docker logs instead of docker compose logs (#44)
* fix: Use docker logs instead of docker compose logs docker compose logs couldn't find containers because the base compose.yml only defines a template service with profiles: ["_template"]. The actual services live in process-specific compose files (compose.web.yml etc). Using docker logs directly with the container name is simpler and works correctly. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fmt --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 76cfbd1 commit 9029de1

File tree

1 file changed

+9
-45
lines changed

1 file changed

+9
-45
lines changed

src/commands/logs.rs

Lines changed: 9 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use anyhow::Result;
22
use clap::Args;
3-
use hl::{config::app_dir, git::infer_app_name, log::*};
3+
use hl::{git::infer_app_name, log::*};
44
use std::process::Stdio;
55
use tokio::process::Command;
66

@@ -13,72 +13,36 @@ pub struct LogsArgs {
1313
/// Number of lines to show from the end of the logs
1414
#[arg(short = 'n', long)]
1515
pub tail: Option<String>,
16-
17-
/// Show logs for specific service (default: all services)
18-
#[arg(short, long)]
19-
pub service: Option<String>,
2016
}
2117

2218
pub async fn execute(args: LogsArgs) -> Result<()> {
2319
let app = infer_app_name().await?;
24-
let dir = app_dir(&app);
25-
26-
debug(&format!("logs: app_dir={}", dir.display()));
2720

28-
if !dir.exists() {
29-
anyhow::bail!("App directory not found: {}", dir.display());
30-
}
31-
32-
let compose_file = dir.join("compose.yml");
33-
if !compose_file.exists() {
34-
anyhow::bail!("compose.yml not found at: {}", compose_file.display());
35-
}
21+
let mut docker_args = vec!["logs".to_string()];
3622

37-
// Build compose file list
38-
let mut compose_args = vec!["-f".to_string(), "compose.yml".to_string()];
39-
40-
// Check for compose.postgres.yml
41-
let postgres_compose = dir.join("compose.postgres.yml");
42-
if postgres_compose.exists() {
43-
compose_args.push("-f".to_string());
44-
compose_args.push("compose.postgres.yml".to_string());
45-
}
46-
47-
compose_args.push("logs".to_string());
48-
49-
// Add follow flag
5023
if args.follow {
51-
compose_args.push("--follow".to_string());
24+
docker_args.push("--follow".to_string());
5225
}
5326

54-
// Add tail flag
5527
if let Some(tail) = args.tail {
56-
compose_args.push("--tail".to_string());
57-
compose_args.push(tail);
28+
docker_args.push("--tail".to_string());
29+
docker_args.push(tail);
5830
}
5931

60-
// Add specific service if specified
61-
if let Some(service) = args.service {
62-
compose_args.push(service);
63-
}
32+
docker_args.push(app.clone());
6433

65-
debug(&format!(
66-
"executing docker compose command: docker compose {}",
67-
compose_args.join(" ")
68-
));
34+
debug(&format!("executing: docker {}", docker_args.join(" ")));
6935

7036
let status = Command::new("docker")
71-
.arg("compose")
72-
.args(&compose_args)
73-
.current_dir(&dir)
37+
.args(&docker_args)
7438
.stdin(Stdio::inherit())
7539
.stdout(Stdio::inherit())
7640
.stderr(Stdio::inherit())
7741
.status()
7842
.await?;
7943

8044
if !status.success() {
81-
anyhow::bail!("docker compose logs failed with status: {}", status);
45+
anyhow::bail!("docker logs failed with status: {}", status);
8246
}
8347

8448
Ok(())

0 commit comments

Comments
 (0)