Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(playground): refinements on connector node #8582

Merged
merged 3 commits into from
Mar 16, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,6 @@ description = "Download all available components at once"
dependencies = [
"download-connector",
"download-maven",
"build-connector-node",
"download-etcd",
"download-grafana",
"download-jaeger",
Expand Down Expand Up @@ -415,6 +414,7 @@ dependencies = [
"create-user-profiles-file",
"download-all",
"build-risingwave",
"build-connector-node",
"post-build-risingwave",
"extract-dashboard-artifact",
"export-dashboard-v2",
Expand All @@ -441,6 +441,7 @@ alias = "playground"
[tasks.playground]
category = "RiseDev - Start"
description = "Start a lite RisingWave playground using risingwave all-in-one binary"
dependencies = ["download-connector"]
script = '''
#!/usr/bin/env bash

Expand Down
34 changes: 20 additions & 14 deletions src/cmd_all/src/playground.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ fn osstrs<const N: usize>(s: [&str; N]) -> Vec<OsString> {
}

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

let profile = if let Ok(profile) = std::env::var("PLAYGROUND_PROFILE") {
profile.to_string()
Expand Down Expand Up @@ -224,22 +224,28 @@ pub async fn playground() -> Result<()> {
.join("start-service.sh");
if cmd_path.exists() {
tracing::info!("start connector-node with prefix_bin {}", prefix_bin);
let mut cmd = Command::new(cmd_path);
cmd.arg("-p").arg("50051");
cmd.stdout(std::process::Stdio::piped());
let mut child = cmd.spawn().expect("failed to start connector node");
let stdout = child.stdout.take().expect("failed to open stdout");
let _child_handle = tokio::spawn(async move { child.wait().await });
let _stdout_handle = tokio::spawn(async move {
let mut reader = BufReader::new(stdout).lines();
while let Some(line) =
reader.next_line().await.expect("failed to read line")
{
eprintln!("{}", line);
let mut child = Command::new(cmd_path)
.arg("-p")
.arg("50051")
.stderr(std::process::Stdio::piped())
.spawn()?;
let stderr = child.stderr.take().unwrap();

let _child_handle = tokio::spawn(async move {
signal::ctrl_c().await.unwrap();
let _ = child.start_kill();
});
Comment on lines +238 to +241
Copy link
Member

@xxchan xxchan Mar 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel this is unnecessary because the child process is already killed currently (how? 🤯). Did you tried the current behavior?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is ok to kill in an explicit way

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel this is unnecessary because the child process is already killed currently

Yes. But I do have encountered situations where the connector node not gets killed. 🤔 Not sure what's happening under the hood.

let _stderr_handle = tokio::spawn(async move {
let mut reader = BufReader::new(stderr).lines();
while let Ok(Some(line)) = reader.next_line().await {
tracing::error!(target: "risingwave_connector_node", "{}", line);
}
});
} else {
eprintln!("connector node path not exist!");
tracing::warn!(
"Will not start connector node since `{}` does not exist.",
cmd_path.display()
);
}
}
}
Expand Down