mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-08-21 00:02:23 +00:00
more observability for dedicated workers
This commit is contained in:
@@ -1014,8 +1014,7 @@ pub async fn start_worker(
|
||||
let args = windmill_parser_ts::parse_deno_signature(inner_content, true, None)?.args;
|
||||
let dates = args
|
||||
.iter()
|
||||
.enumerate()
|
||||
.filter_map(|(i, x)| {
|
||||
.filter_map(|x| {
|
||||
if matches!(x.typ, Typ::Datetime) {
|
||||
Some(x.name.clone())
|
||||
} else {
|
||||
@@ -1050,7 +1049,6 @@ BigInt.prototype.toJSON = function () {{
|
||||
return this.toString();
|
||||
}};
|
||||
|
||||
|
||||
console.log('start');
|
||||
|
||||
for await (const line of Readline.createInterface({{ input: process.stdin }})) {{
|
||||
|
||||
@@ -151,12 +151,18 @@ pub async fn handle_dedicated_process(
|
||||
},
|
||||
line = err_reader.next_line() => {
|
||||
if let Some(line) = line.expect("line is ok") {
|
||||
tracing::debug!("stderr dedicated worker: {line}");
|
||||
tracing::error!("stderr dedicated worker: {line}");
|
||||
logs.push_str("[stderr] ");
|
||||
logs.push_str(&line);
|
||||
logs.push_str("\n");
|
||||
} else {
|
||||
tracing::info!("dedicated worker process exited {script_path}");
|
||||
let mut last_stdout = "".to_string();
|
||||
while let Some(line) = reader.next_line().await.ok().flatten() {
|
||||
last_stdout = line;
|
||||
last_stdout.push_str("\n");
|
||||
}
|
||||
tracing::info!("Last stdout for {script_path}: {last_stdout}");
|
||||
break;
|
||||
}
|
||||
},
|
||||
@@ -193,7 +199,13 @@ pub async fn handle_dedicated_process(
|
||||
logs.push_str("\n");
|
||||
}
|
||||
} else {
|
||||
tracing::info!("dedicated worker process exited");
|
||||
tracing::info!("dedicated worker {script_path} process exited");
|
||||
let mut last_stderr = "".to_string();
|
||||
while let Some(line) = err_reader.next_line().await.ok().flatten() {
|
||||
last_stderr = line;
|
||||
last_stderr.push_str("\n");
|
||||
}
|
||||
tracing::info!("Last stderr for {script_path}: {last_stderr}");
|
||||
break;
|
||||
}
|
||||
},
|
||||
@@ -220,6 +232,7 @@ pub async fn handle_dedicated_process(
|
||||
child
|
||||
.await
|
||||
.map_err(|e| anyhow::anyhow!("child process {script_path} encountered an error: {e:#}"))?;
|
||||
|
||||
tracing::info!("dedicated worker {script_path} child process exited successfully");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -444,15 +444,14 @@ pub async fn start_worker(
|
||||
let args = windmill_parser_ts::parse_deno_signature(inner_content, true, None)?.args;
|
||||
let dates = args
|
||||
.iter()
|
||||
.enumerate()
|
||||
.filter_map(|(i, x)| {
|
||||
.filter_map(|x| {
|
||||
if matches!(x.typ, Typ::Datetime) {
|
||||
Some(i)
|
||||
Some(x.name.clone())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
.map(|x| return format!("args[{x}] = args[{x}] ? new Date(args[{x}]) : undefined"))
|
||||
.map(|x| return format!("{x} = {x} ? new Date({x}) : undefined"))
|
||||
.join("\n");
|
||||
|
||||
let spread = args.into_iter().map(|x| x.name).join(",");
|
||||
@@ -481,6 +480,7 @@ for await (const chunk of Deno.stdin.readable) {{
|
||||
}}
|
||||
try {{
|
||||
let {{ {spread} }} = JSON.parse(line)
|
||||
{dates}
|
||||
let res: any = await main(...[ {spread} ]);
|
||||
console.log("wm_res[success]:" + JSON.stringify(res ?? null, (key, value) => typeof value === 'undefined' ? null : value) + '\n');
|
||||
}} catch (e) {{
|
||||
|
||||
Reference in New Issue
Block a user