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

Class TimeCheck

daemon/src/entity/commands/task/time.ts:5–30  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3
4// When the instance is running, continue to check the expiration time
5export default class TimeCheck implements ILifeCycleTask {
6 public status: number = 0;
7 public name: string = "TimeCheck";
8
9 private task: any = null;
10
11 async start(instance: Instance) {
12 this.task = setInterval(async () => {
13 if (instance.config.endTime) {
14 const endTime = instance.config.endTime;
15 if (endTime) {
16 const currentTime = Date.now();
17 if (endTime <= currentTime) {
18 // Expired, execute the end process command
19 await instance.execPreset("kill");
20 clearInterval(this.task);
21 }
22 }
23 }
24 }, 1000 * 60 * 60);
25 }
26
27 async stop(instance: Instance) {
28 clearInterval(this.task);
29 }
30}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected