| 3 | |
| 4 | // When the instance is running, continue to check the expiration time |
| 5 | export 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 | } |
nothing calls this directly
no outgoing calls
no test coverage detected