mirror of
https://github.com/uqbar-dao/nectar.git
synced 2024-12-23 08:32:23 +03:00
fix on_panic::restart
This commit is contained in:
parent
c806bc099f
commit
53c84abaec
@ -1210,11 +1210,7 @@ async fn make_process_loop(
|
|||||||
};
|
};
|
||||||
|
|
||||||
if is_error {
|
if is_error {
|
||||||
// fulfill the designated OnPanic behavior
|
// get caps before killing
|
||||||
match metadata.on_panic {
|
|
||||||
t::OnPanic::None => {}
|
|
||||||
// if restart, tell ourselves to init the app again, with same capabilities
|
|
||||||
t::OnPanic::Restart => {
|
|
||||||
let (tx, rx) = tokio::sync::oneshot::channel();
|
let (tx, rx) = tokio::sync::oneshot::channel();
|
||||||
let _ = caps_oracle
|
let _ = caps_oracle
|
||||||
.send(t::CapMessage::GetAll {
|
.send(t::CapMessage::GetAll {
|
||||||
@ -1226,16 +1222,9 @@ async fn make_process_loop(
|
|||||||
.await
|
.await
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|cap| t::SignedCapability {
|
|
||||||
issuer: cap.issuer.clone(),
|
|
||||||
params: cap.params.clone(),
|
|
||||||
signature: keypair
|
|
||||||
.sign(&bincode::serialize(&cap).unwrap())
|
|
||||||
.as_ref()
|
|
||||||
.to_vec(),
|
|
||||||
})
|
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
|
// always send message to tell main kernel loop to remove handler
|
||||||
send_to_loop
|
send_to_loop
|
||||||
.send(t::KernelMessage {
|
.send(t::KernelMessage {
|
||||||
id: rand::random(),
|
id: rand::random(),
|
||||||
@ -1246,12 +1235,42 @@ async fn make_process_loop(
|
|||||||
inherit: false,
|
inherit: false,
|
||||||
expects_response: None,
|
expects_response: None,
|
||||||
ipc: Some(
|
ipc: Some(
|
||||||
serde_json::to_string(&t::KernelCommand::StartProcess {
|
serde_json::to_string(&t::KernelCommand::KillProcess(
|
||||||
id: metadata.our.process.clone(),
|
metadata.our.process.clone(),
|
||||||
|
))
|
||||||
|
.unwrap(),
|
||||||
|
),
|
||||||
|
metadata: None,
|
||||||
|
}),
|
||||||
|
payload: None,
|
||||||
|
signed_capabilities: None,
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
// fulfill the designated OnPanic behavior
|
||||||
|
match metadata.on_panic {
|
||||||
|
t::OnPanic::None => {}
|
||||||
|
// if restart, tell ourselves to init the app again, with same capabilities
|
||||||
|
t::OnPanic::Restart => {
|
||||||
|
send_to_loop
|
||||||
|
.send(t::KernelMessage {
|
||||||
|
id: rand::random(),
|
||||||
|
source: our_kernel.clone(),
|
||||||
|
target: our_kernel.clone(),
|
||||||
|
rsvp: None,
|
||||||
|
message: t::Message::Request(t::Request {
|
||||||
|
inherit: false,
|
||||||
|
expects_response: None,
|
||||||
|
ipc: Some(
|
||||||
|
serde_json::to_string(&t::KernelCommand::RebootProcess {
|
||||||
|
process_id: metadata.our.process.clone(),
|
||||||
|
persisted: t::PersistedProcess {
|
||||||
wasm_bytes_handle: metadata.wasm_bytes_handle,
|
wasm_bytes_handle: metadata.wasm_bytes_handle,
|
||||||
on_panic: metadata.on_panic,
|
on_panic: metadata.on_panic,
|
||||||
initial_capabilities,
|
capabilities: initial_capabilities,
|
||||||
public: metadata.public,
|
public: metadata.public,
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
),
|
),
|
||||||
@ -1285,30 +1304,6 @@ async fn make_process_loop(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// always send message to tell main kernel loop to remove handler
|
|
||||||
send_to_loop
|
|
||||||
.send(t::KernelMessage {
|
|
||||||
id: rand::random(),
|
|
||||||
source: our_kernel.clone(),
|
|
||||||
target: our_kernel.clone(),
|
|
||||||
rsvp: None,
|
|
||||||
message: t::Message::Request(t::Request {
|
|
||||||
inherit: false,
|
|
||||||
expects_response: None,
|
|
||||||
ipc: Some(
|
|
||||||
serde_json::to_string(&t::KernelCommand::KillProcess(
|
|
||||||
metadata.our.process.clone(),
|
|
||||||
))
|
|
||||||
.unwrap(),
|
|
||||||
),
|
|
||||||
metadata: None,
|
|
||||||
}),
|
|
||||||
payload: None,
|
|
||||||
signed_capabilities: None,
|
|
||||||
})
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
Ok(())
|
Ok(())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user