@@ -162,7 +162,7 @@ fn osstrs<const N: usize>(s: [&str; N]) -> Vec<OsString> {
162
162
}
163
163
164
164
pub async fn playground ( ) -> Result < ( ) > {
165
- eprintln ! ( "launching playground" ) ;
165
+ tracing :: info !( "launching playground" ) ;
166
166
167
167
let profile = if let Ok ( profile) = std:: env:: var ( "PLAYGROUND_PROFILE" ) {
168
168
profile. to_string ( )
@@ -228,22 +228,28 @@ pub async fn playground() -> Result<()> {
228
228
. join ( "start-service.sh" ) ;
229
229
if cmd_path. exists ( ) {
230
230
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) ;
243
246
}
244
247
} ) ;
245
248
} 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
+ ) ;
247
253
}
248
254
}
249
255
}
0 commit comments