packages/slave/slave.js
/**
	 * Stops all instances and closes the connection
	 */
Stops all instances and closes the connection
Stops all instances and closes the connection
async shutdown() {
		if (this._shuttingDown) {
			return;
		}
		this._shuttingDown = true;
		try {
			await libLink.messages.prepareDisconnect.send(this);
		} catch (err) {
			if (!(err instanceof libErrors.SessionLost)) {
				logger.error(`Unexpected error preparing disconnect:\n${err.stack}`);
			}
		}
		try {
			for (let instanceId of this.instanceConnections.keys()) {
				await this.stopInstance(instanceId);
			}
			await this.connector.close(1000, "Slave Shutdown");
			pidusage.clear();
		} catch (err) {
			setBlocking(true);
			logger.error(`
+------------------------------------------------------------+
| Unexpected error occured while shutting down slave, please |
| report it to https://github.com/clusterio/clusterio/issues |
+------------------------------------------------------------+
${err.stack}`
			);
			process.exit(1);
		}
	}
async shutdown ( ) { if ( this . _shuttingDown ) { return ; } this . _shuttingDown = true ; try { await libLink . messages . prepareDisconnect . send ( this ) ; } catch ( err ) { if ( ! ( err instanceof libErrors . SessionLost ) ) { logger . error ( ` \n ${ err . stack } ` ) ; } } try { for ( let instanceId of this . instanceConnections . keys ( ) ) { await this . stopInstance ( instanceId ) ; } await this . connector . close ( 1000 , "Slave Shutdown" ) ; pidusage . clear ( ) ; } catch ( err ) { setBlocking ( true ) ; logger . error ( ` ${ err . stack } ` ) ; process . exit ( 1 ) ; } }
Stops all instances and closes the connection
Stops all instances and closes the connection
// Clear silly interval in pidfile library. // eslint-disable-next-line node/no-process-exit