src/api2/node/tasks.rs: implement stop_task api
This commit is contained in:
parent
98a181f055
commit
a665dea128
|
@ -92,6 +92,21 @@ fn read_task_log(
|
|||
Ok(json!(lines))
|
||||
}
|
||||
|
||||
fn stop_task(
|
||||
param: Value,
|
||||
_info: &ApiMethod,
|
||||
_rpcenv: &mut RpcEnvironment,
|
||||
) -> Result<Value, Error> {
|
||||
|
||||
let upid = extract_upid(¶m)?;
|
||||
|
||||
if crate::server::worker_is_active(&upid) {
|
||||
server::abort_worker_async(upid);
|
||||
}
|
||||
|
||||
Ok(Value::Null)
|
||||
}
|
||||
|
||||
fn list_tasks(
|
||||
param: Value,
|
||||
_info: &ApiMethod,
|
||||
|
@ -171,6 +186,13 @@ pub fn router() -> Router {
|
|||
.required("node", crate::api2::node::NODE_SCHEMA.clone())
|
||||
.required("upid", upid_schema.clone()))
|
||||
)
|
||||
.delete(ApiMethod::new(
|
||||
stop_task,
|
||||
ObjectSchema::new("Try to stop a task.")
|
||||
.required("node", crate::api2::node::NODE_SCHEMA.clone())
|
||||
.required("upid", upid_schema.clone())).protected(true)
|
||||
|
||||
)
|
||||
.subdir(
|
||||
"log", Router::new()
|
||||
.get(
|
||||
|
|
Loading…
Reference in New Issue