src/api2/node/tasks.rs: fix task status api
This commit is contained in:
parent
0bfd87bc5e
commit
c360bd73d3
|
@ -18,14 +18,23 @@ fn get_task_status(
|
||||||
|
|
||||||
let upid = extract_upid(¶m)?;
|
let upid = extract_upid(¶m)?;
|
||||||
|
|
||||||
let result = if crate::server::worker_is_active(&upid) {
|
let mut result = json!({
|
||||||
json!({
|
"upid": param["upid"],
|
||||||
"status": "running",
|
"node": upid.node,
|
||||||
})
|
"pid": upid.pid,
|
||||||
|
"pstart": upid.pstart,
|
||||||
|
"starttime": upid.starttime,
|
||||||
|
"type": upid.worker_type,
|
||||||
|
"id": upid.worker_id,
|
||||||
|
"user": upid.username,
|
||||||
|
});
|
||||||
|
|
||||||
|
if crate::server::worker_is_active(&upid) {
|
||||||
|
result["status"] = Value::from("running");
|
||||||
} else {
|
} else {
|
||||||
json!({
|
let exitstatus = crate::server::upid_read_status(&upid).unwrap_or(String::from("unknown"));
|
||||||
"status": "stopped",
|
result["status"] = Value::from("stopped");
|
||||||
})
|
result["exitstatus"] = Value::from(exitstatus);
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(result)
|
Ok(result)
|
||||||
|
|
Loading…
Reference in New Issue