From c360bd73d37cfa0054e3a0f0bdf9bffe6e3f7197 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Tue, 9 Apr 2019 15:12:20 +0200 Subject: [PATCH] src/api2/node/tasks.rs: fix task status api --- src/api2/node/tasks.rs | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/api2/node/tasks.rs b/src/api2/node/tasks.rs index be5d34f1..039383bd 100644 --- a/src/api2/node/tasks.rs +++ b/src/api2/node/tasks.rs @@ -18,14 +18,23 @@ fn get_task_status( let upid = extract_upid(¶m)?; - let result = if crate::server::worker_is_active(&upid) { - json!({ - "status": "running", - }) + let mut result = json!({ + "upid": param["upid"], + "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 { - json!({ - "status": "stopped", - }) + let exitstatus = crate::server::upid_read_status(&upid).unwrap_or(String::from("unknown")); + result["status"] = Value::from("stopped"); + result["exitstatus"] = Value::from(exitstatus); }; Ok(result)