MCPcopy Create free account
hub / github.com/Botloader/botloader / handle_shutdown_msg

Method handle_shutdown_msg

components/scheduler/src/vm_session.rs:273–325  ·  view source on GitHub ↗
(&mut self, shutdown: VmSessionShutdownEvent)

Source from the content-addressed store, hash-verified

271 }
272
273 fn handle_shutdown_msg(&mut self, shutdown: VmSessionShutdownEvent) -> Vec<SessionEvent> {
274 if shutdown.guild_id != self.guild_id {
275 // shutdown of the previous tenant's vm being drained by the worker
276 return Vec::new();
277 }
278
279 let mut events = self.cancel_old_vm_session_pending_acks(shutdown.vm_session_id);
280
281 match shutdown.reason {
282 Some(ShutdownReason::DiscordInvalidRequestsRatelimit) => {
283 self.logger.log(CreateLogEntry::critical(
284 "VM was forcibly shut down for issuing too many invalid discord \
285 requests. Your guild has also been temporarily blacklisted for this \
286 reason."
287 .to_string(),
288 ));
289 }
290 Some(ShutdownReason::Runaway) => {
291 self.logger.log(CreateLogEntry::critical(
292 "VM was forcibly shut down for blocking the thread for too long, this \
293 means you might have an infinite loop somewhere."
294 .to_string(),
295 ));
296 }
297 Some(ShutdownReason::OutOfMemory) => {
298 self.logger.log(CreateLogEntry::critical(
299 "VM ran out of memory, this should not normally happen from normal \
300 use but if this was not intentional abuse please join the support \
301 server and let us know."
302 .to_owned(),
303 ));
304 warn!("VM ran out of memory");
305 }
306 Some(ShutdownReason::Request) => {
307 self.logger.log(CreateLogEntry::info(
308 "Vm was shut down gracefully.".to_owned(),
309 ));
310 }
311 None => {
312 error!("Unknown vm shutdown reason");
313 self.logger.log(CreateLogEntry::error(
314 "Vm was shut down due to a unknown reason?".to_owned(),
315 ));
316 }
317 }
318
319 events.push(SessionEvent::VmShutdown {
320 current_vm: shutdown.vm_session_id == self.vm_session_id,
321 reason: shutdown.reason,
322 });
323
324 events
325 }
326
327 fn cancel_old_vm_session_pending_acks(&mut self, session_id: u64) -> Vec<SessionEvent> {
328 let to_cancel = self

Callers 1

handle_worker_msgMethod · 0.80

Calls 3

errorFunction · 0.85
logMethod · 0.80

Tested by

no test coverage detected