Notify superseded plugin processes and support SDK draining
This commit is contained in:
@@ -12,6 +12,7 @@ pub(crate) struct OldProcess {
|
||||
pub(crate) struct Upgrade {
|
||||
plugin: String,
|
||||
previous: String,
|
||||
current: String,
|
||||
grace: Duration,
|
||||
processes: Vec<OldProcess>,
|
||||
services: Vec<(Service, Option<watch::Receiver<bool>>)>,
|
||||
@@ -67,6 +68,7 @@ impl Host {
|
||||
Upgrade {
|
||||
plugin: plugin.into(),
|
||||
previous,
|
||||
current: current.into(),
|
||||
grace: Duration::from_secs_f64(grace),
|
||||
processes,
|
||||
services,
|
||||
@@ -74,6 +76,13 @@ impl Host {
|
||||
}
|
||||
/// Lets old calls finish, stops them after grace, and starts each lifecycle hook once.
|
||||
pub(crate) fn begin_upgrade(&self, upgrade: Upgrade) {
|
||||
// Queue the notice before returning from activation, without waiting on guest code.
|
||||
for process in &upgrade.processes {
|
||||
self.send(
|
||||
&process.pid,
|
||||
json!({"jsonrpc":"2.0","method":"rpc.superseded","params":{"current":upgrade.current}}),
|
||||
);
|
||||
}
|
||||
let host = self.clone();
|
||||
tokio::spawn(async move {
|
||||
if host.0.shutdown.load(Ordering::SeqCst) {
|
||||
|
||||
Reference in New Issue
Block a user