Skip to content

Commit 582307d

Browse files
refactor(playground): refinements on connector node (risingwavelabs#8582)
Signed-off-by: Bugen Zhao <[email protected]> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
1 parent 9b89bb0 commit 582307d

File tree

2 files changed

+22
-15
lines changed

2 files changed

+22
-15
lines changed

Makefile.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,6 @@ description = "Download all available components at once"
371371
dependencies = [
372372
"download-connector",
373373
"download-maven",
374-
"build-connector-node",
375374
"download-etcd",
376375
"download-grafana",
377376
"download-jaeger",
@@ -415,6 +414,7 @@ dependencies = [
415414
"create-user-profiles-file",
416415
"download-all",
417416
"build-risingwave",
417+
"build-connector-node",
418418
"post-build-risingwave",
419419
"extract-dashboard-artifact",
420420
"export-dashboard-v2",
@@ -441,6 +441,7 @@ alias = "playground"
441441
[tasks.playground]
442442
category = "RiseDev - Start"
443443
description = "Start a lite RisingWave playground using risingwave all-in-one binary"
444+
dependencies = ["download-connector"]
444445
script = '''
445446
#!/usr/bin/env bash
446447

src/cmd_all/src/playground.rs

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ fn osstrs<const N: usize>(s: [&str; N]) -> Vec<OsString> {
162162
}
163163

164164
pub async fn playground() -> Result<()> {
165-
eprintln!("launching playground");
165+
tracing::info!("launching playground");
166166

167167
let profile = if let Ok(profile) = std::env::var("PLAYGROUND_PROFILE") {
168168
profile.to_string()
@@ -228,22 +228,28 @@ pub async fn playground() -> Result<()> {
228228
.join("start-service.sh");
229229
if cmd_path.exists() {
230230
tracing::info!("start connector-node with prefix_bin {}", prefix_bin);
231-
let mut cmd = Command::new(cmd_path);
232-
cmd.arg("-p").arg("50051");
233-
cmd.stdout(std::process::Stdio::piped());
234-
let mut child = cmd.spawn().expect("failed to start connector node");
235-
let stdout = child.stdout.take().expect("failed to open stdout");
236-
let _child_handle = tokio::spawn(async move { child.wait().await });
237-
let _stdout_handle = tokio::spawn(async move {
238-
let mut reader = BufReader::new(stdout).lines();
239-
while let Some(line) =
240-
reader.next_line().await.expect("failed to read line")
241-
{
242-
eprintln!("{}", line);
231+
let mut child = Command::new(cmd_path)
232+
.arg("-p")
233+
.arg("50051")
234+
.stderr(std::process::Stdio::piped())
235+
.spawn()?;
236+
let stderr = child.stderr.take().unwrap();
237+
238+
let _child_handle = tokio::spawn(async move {
239+
signal::ctrl_c().await.unwrap();
240+
let _ = child.start_kill();
241+
});
242+
let _stderr_handle = tokio::spawn(async move {
243+
let mut reader = BufReader::new(stderr).lines();
244+
while let Ok(Some(line)) = reader.next_line().await {
245+
tracing::error!(target: "risingwave_connector_node", "{}", line);
243246
}
244247
});
245248
} else {
246-
eprintln!("connector node path not exist!");
249+
tracing::warn!(
250+
"Will not start connector node since `{}` does not exist.",
251+
cmd_path.display()
252+
);
247253
}
248254
}
249255
}

0 commit comments

Comments
 (0)