packages/slave/slave.js
/**
	 * Discover available instances
	 *
	 * Looks through the instances directory for instances and updates
	 * the slave and master server with the new list of instances.
	 */
Discover available instances
Looks through the instances directory for instances and updates
the slave and master server with the new list of instances.
Discover available instances Looks through the instances directory for instances and updates the slave and master server with the new list of instances .
async updateInstances() {
		this.discoveredInstanceInfos = await discoverInstances(this.config.get("slave.instances_directory"));
		let list = [];
		for (let [instanceId, instanceInfo] of this.discoveredInstanceInfos) {
			let instanceConnection = this.instanceConnections.get(instanceId);
			list.push({
				serialized_config: instanceInfo.config.serialize("master"),
				status: instanceConnection ? instanceConnection.status : "stopped",
			});
		}
		await libLink.messages.updateInstances.send(this, { instances: list });
		if (this._startup) {
			this._startup = false;
			for (let [instanceId, instanceInfo] of this.instanceInfos) {
				if (instanceInfo.config.get("instance.auto_start")) {
					try {
						let instanceConnection = await this._connectInstance(instanceId);
						await libLink.messages.startInstance.send(instanceConnection, {
							instance_id: instanceId,
							save: null,
						});
					} catch (err) {
						logger.error(
							`Error during auto startup for ${instanceInfo.config.get("instance.name")}:\n${err.stack}`
						);
					}
				}
			}
		}
	}
async updateInstances ( ) { this . discoveredInstanceInfos = await discoverInstances ( this . config . get ( "slave.instances_directory" ) ) ; let list = [ ] ; for ( let [ instanceId , instanceInfo ] of this . discoveredInstanceInfos ) { let instanceConnection = this . instanceConnections . get ( instanceId ) ; list . push ( { serialized_config : instanceInfo . config . serialize ( "master" ) , status : instanceConnection ? instanceConnection . status : "stopped" , } ) ; } await libLink . messages . updateInstances . send ( this , { instances : list } ) ; if ( this . _startup ) { this . _startup = false ; for ( let [ instanceId , instanceInfo ] of this . instanceInfos ) { if ( instanceInfo . config . get ( "instance.auto_start" ) ) { try { let instanceConnection = await this . _connectInstance ( instanceId ) ; await libLink . messages . startInstance . send ( instanceConnection , { instance_id : instanceId , save : null , } ) ; } catch ( err ) { logger . error ( ` ${ instanceInfo . config . get ( "instance.name" ) } \n ${ err . stack } ` ) ; } } } } }
Discover available instances
 Looks through the instances directory for instances and updates
 the slave and master server with the new list of instances.
Discover available instances Looks through the instances directory for instances and updates the slave and master server with the new list of instances .
// Handle configured auto startup instances