MCPcopy Create free account
hub / github.com/MCSManager/MCSManager / stopped

Method stopped

daemon/src/entity/instance/instance.ts:382–424  ·  view source on GitHub ↗
(code = 0)

Source from the content-addressed store, hash-verified

380 // function that must be executed after the instance has been closed
381 // trigger exit event
382 stopped(code = 0) {
383 // Close all lifecycle tasks
384 this.stopOutputLoop();
385 this.println("INFO", $t("TXT_CODE_70ce6fbb"));
386 this.releaseResources();
387 if (this.instanceStatus != Instance.STATUS_STOP) {
388 this.instanceStatus = Instance.STATUS_STOP;
389 this.startTimestamp = 0;
390 this.emit("exit", code);
391 StorageSubsystem.store("InstanceConfig", this.instanceUuid, this.config);
392 }
393
394 this.lifeCycleTaskManager.execLifeCycleTask(0);
395
396 // If automatic restart is enabled, the startup operation is performed immediately
397 if (!this.config.eventTask.ignore && this.config.eventTask.autoRestart) {
398 const maxAutoRestartCount = this.config.eventTask.autoRestartMaxTimes;
399 if (maxAutoRestartCount == -1 || this.autoRestartCount < maxAutoRestartCount) {
400 this.execPreset("start")
401 .then(() => {
402 this.autoRestartCount++;
403 this.println($t("TXT_CODE_instanceConf.info"), $t("TXT_CODE_instanceConf.autoRestart"));
404 })
405 .catch((err) => {
406 this.println(
407 $t("TXT_CODE_instanceConf.error"),
408 $t("TXT_CODE_instanceConf.autoRestartErr", { err: err })
409 );
410 });
411 } else {
412 this.println($t("TXT_CODE_instanceConf.error"), $t("TXT_CODE_894b8e52"));
413 }
414 }
415
416 this.config.eventTask.ignore = false;
417
418 // Turn off the warning immediately after startup, usually the startup command is written incorrectly
419 const currentTimestamp = new Date().getTime();
420 const startThreshold = 2 * 1000;
421 if (currentTimestamp - this.startTimestamp < startThreshold) {
422 this.println("ERROR", $t("TXT_CODE_aae2918f"));
423 }
424 }
425
426 ignoreEventTaskOnce() {
427 if (this.config.eventTask) this.config.eventTask.ignore = true;

Callers 1

startedMethod · 0.95

Calls 8

stopOutputLoopMethod · 0.95
printlnMethod · 0.95
releaseResourcesMethod · 0.95
execPresetMethod · 0.95
$tFunction · 0.90
emitMethod · 0.80
execLifeCycleTaskMethod · 0.80
storeMethod · 0.65

Tested by

no test coverage detected