Skip to content

Commit 59229a8

Browse files
committed
fix: cli start should honour existing db connections and only check docker when it can not connect
1 parent 5820c9a commit 59229a8

File tree

2 files changed

+19
-13
lines changed

2 files changed

+19
-13
lines changed

crates/cli/src/commands/start.rs

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,26 @@ pub async fn handle_start(project_path: &PathBuf) -> Result<(), ProjectStartupEr
1616

1717
rrelayer_info!("Starting relayer...");
1818

19-
let docker_compose_path = project_path.join("docker-compose.yml");
20-
if !docker_compose_path.exists() {
21-
return Err(ProjectStartupError::DockerComposeNotFound);
22-
}
23-
24-
match start_docker_compose(project_path) {
25-
Ok(_) => {
26-
rrelayer_info!("Docker postgres containers started up successfully");
19+
// check connection of the database as they may have it connected already (prod releases etc)
20+
let connection_alive = PostgresClient::new().await;
21+
if connection_alive.is_err() {
22+
let docker_compose_path = project_path.join("docker-compose.yml");
23+
if !docker_compose_path.exists() {
24+
return Err(ProjectStartupError::DockerComposeNotFound);
2725
}
28-
Err(e) => {
29-
return Err(e);
26+
27+
match start_docker_compose(project_path) {
28+
Ok(_) => {
29+
rrelayer_info!("Docker postgres containers started up successfully");
30+
}
31+
Err(e) => {
32+
return Err(e);
33+
}
3034
}
31-
}
3235

33-
// check connection of the database
34-
let _ = PostgresClient::new().await?;
36+
// check connection of the database now with docker up
37+
let _ = PostgresClient::new().await?;
38+
}
3539

3640
start(project_path).await?;
3741

documentation/rrelayer/docs/pages/changelog.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
### Bug fixes
1212

13+
- fix: cli start should honour existing db connections and only check docker when it can not connect
14+
1315
---
1416

1517
### Breaking changes

0 commit comments

Comments
 (0)