(&mut self, new_scripts: Vec<Script>)
| 536 | } |
| 537 | |
| 538 | async fn restart(&mut self, new_scripts: Vec<Script>) { |
| 539 | self.guild_logger |
| 540 | .log(CreateLogEntry::info("restarting guild vm...".to_string())); |
| 541 | |
| 542 | self.stop_vm().await; |
| 543 | |
| 544 | // create a new sandbox |
| 545 | { |
| 546 | let mut borrow = self.script_store.borrow_mut(); |
| 547 | borrow.clear(); |
| 548 | }; |
| 549 | |
| 550 | for script in &new_scripts { |
| 551 | self.compile_script(script.clone()); |
| 552 | } |
| 553 | |
| 554 | let new_rt = Self::create_isolate( |
| 555 | &self.extension_factory, |
| 556 | self.module_manager.clone(), |
| 557 | self.script_store.clone(), |
| 558 | self.shutdown_handle.clone(), |
| 559 | ); |
| 560 | |
| 561 | self.runtime = new_rt; |
| 562 | self.emit_isolate_handle(); |
| 563 | |
| 564 | for script in new_scripts { |
| 565 | self.run_script(script.id).await; |
| 566 | } |
| 567 | |
| 568 | self.guild_logger |
| 569 | .log(CreateLogEntry::info("vm restarted".to_string())); |
| 570 | } |
| 571 | } |
| 572 | |
| 573 | pub enum TickResult { |
no test coverage detected