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,32 +1210,49 @@ async fn make_process_loop(
|
|||||||
};
|
};
|
||||||
|
|
||||||
if is_error {
|
if is_error {
|
||||||
|
// get caps before killing
|
||||||
|
let (tx, rx) = tokio::sync::oneshot::channel();
|
||||||
|
let _ = caps_oracle
|
||||||
|
.send(t::CapMessage::GetAll {
|
||||||
|
on: metadata.our.process.clone(),
|
||||||
|
responder: tx,
|
||||||
|
})
|
||||||
|
.await;
|
||||||
|
let initial_capabilities = rx
|
||||||
|
.await
|
||||||
|
.unwrap()
|
||||||
|
.into_iter()
|
||||||
|
.collect();
|
||||||
|
|
||||||
|
// 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();
|
||||||
|
|
||||||
// fulfill the designated OnPanic behavior
|
// fulfill the designated OnPanic behavior
|
||||||
match metadata.on_panic {
|
match metadata.on_panic {
|
||||||
t::OnPanic::None => {}
|
t::OnPanic::None => {}
|
||||||
// if restart, tell ourselves to init the app again, with same capabilities
|
// if restart, tell ourselves to init the app again, with same capabilities
|
||||||
t::OnPanic::Restart => {
|
t::OnPanic::Restart => {
|
||||||
let (tx, rx) = tokio::sync::oneshot::channel();
|
|
||||||
let _ = caps_oracle
|
|
||||||
.send(t::CapMessage::GetAll {
|
|
||||||
on: metadata.our.process.clone(),
|
|
||||||
responder: tx,
|
|
||||||
})
|
|
||||||
.await;
|
|
||||||
let initial_capabilities = rx
|
|
||||||
.await
|
|
||||||
.unwrap()
|
|
||||||
.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();
|
|
||||||
|
|
||||||
send_to_loop
|
send_to_loop
|
||||||
.send(t::KernelMessage {
|
.send(t::KernelMessage {
|
||||||
id: rand::random(),
|
id: rand::random(),
|
||||||
@ -1246,12 +1263,14 @@ 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::RebootProcess {
|
||||||
id: metadata.our.process.clone(),
|
process_id: metadata.our.process.clone(),
|
||||||
wasm_bytes_handle: metadata.wasm_bytes_handle,
|
persisted: t::PersistedProcess {
|
||||||
on_panic: metadata.on_panic,
|
wasm_bytes_handle: metadata.wasm_bytes_handle,
|
||||||
initial_capabilities,
|
on_panic: metadata.on_panic,
|
||||||
public: metadata.public,
|
capabilities: initial_capabilities,
|
||||||
|
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