()
| 164 | } |
| 165 | |
| 166 | private startRemainingTimer() { |
| 167 | let me = this; |
| 168 | |
| 169 | this.remainingTime = this.expireDate ? (<any>(new Date(this.expireDate)) - <any>new Date()) : undefined; |
| 170 | if (!this.remainingTime) return me.stopRemainingTimer(); |
| 171 | |
| 172 | if (this.remainingTime <= 0) { |
| 173 | return process.nextTick(() => { |
| 174 | console.info(`${me.port} expired. ${me.expireDate} ${me.remainingTime}`); |
| 175 | me.stop(); |
| 176 | }); |
| 177 | } |
| 178 | |
| 179 | this.stopRemainingTimer(); |
| 180 | |
| 181 | this.remainingTimer = setInterval(() => { |
| 182 | me.remainingTime -= LsServer.expireRefreshInterval; |
| 183 | if (me.remainingTime > 0) return; |
| 184 | |
| 185 | console.info(`${me.port} expired. ${me.expireDate} ${me.remainingTime}`); |
| 186 | me.stop(); |
| 187 | }, LsServer.expireRefreshInterval); |
| 188 | |
| 189 | this.remainingTimer.unref(); |
| 190 | } |
| 191 | |
| 192 | private stopRemainingTimer() { |
| 193 | if (!this.remainingTimer) return; |
no test coverage detected