packages/slave/slave.js
/**
 * Searches for instances in the provided directory
 *
 * Looks through all sub-dirs of the provided directory for valid
 * instance definitions and return a mapping of instance id to
 * instanceInfo objects.
 *
 * @param {string} instancesDir - Directory containing instances
 * @returns {Map<integer, Object>}
 *     mapping between instance id and information about this instance.
 */
Searches for instances in the provided directory
Looks through all sub-dirs of the provided directory for valid
instance definitions and return a mapping of instance id to
instanceInfo objects.

@param {string} instancesDir - Directory containing instances
@returns {Map}
mapping between instance id and information about this instance.
Searches for instances in the provided directory Looks through all sub - dirs of the provided directory for valid instance definitions and return a mapping of instance id to instanceInfo objects . @param { string } instancesDir - Directory containing instances @returns { Map } mapping between instance id and information about this instance .
async function discoverInstances(instancesDir) {
	let instanceInfos = new Map();
	for (let entry of await fs.readdir(instancesDir, { withFileTypes: true })) {
		if (entry.isDirectory()) {
			let instanceConfig = new libConfig.InstanceConfig("slave");
			let configPath = path.join(instancesDir, entry.name, "instance.json");
			try {
				await instanceConfig.load(JSON.parse(await fs.readFile(configPath)));
			} catch (err) {
				if (err.code === "ENOENT") {
					continue; 
				}
				logger.error(`Error occured while parsing ${configPath}: ${err.message}`);
				continue;
			}
			let instancePath = path.join(instancesDir, entry.name);
			logger.verbose(`found instance ${instanceConfig.get("instance.name")} in ${instancePath}`);
			instanceInfos.set(instanceConfig.get("instance.id"), {
				path: instancePath,
				config: instanceConfig,
			});
		}
	}
	return instanceInfos;
}
async function discoverInstances ( instancesDir ) { let instanceInfos = new Map ( ) ; for ( let entry of await fs . readdir ( instancesDir , { withFileTypes : true } ) ) { if ( entry . isDirectory ( ) ) { let instanceConfig = new libConfig . InstanceConfig ( "slave" ) ; let configPath = path . join ( instancesDir , entry . name , "instance.json" ) ; try { await instanceConfig . load ( JSON . parse ( await fs . readFile ( configPath ) ) ) ; } catch ( err ) { if ( err . code === "ENOENT" ) { continue ; } logger . error ( ` ${ configPath } ${ err . message } ` ) ; continue ; } let instancePath = path . join ( instancesDir , entry . name ) ; logger . verbose ( ` ${ instanceConfig . get ( "instance.name" ) } ${ instancePath } ` ) ; instanceInfos . set ( instanceConfig . get ( "instance.id" ) , { path : instancePath , config : instanceConfig , } ) ; } } return instanceInfos ; }
Searches for instances in the provided directory
 Looks through all sub-dirs of the provided directory for valid
 instance definitions and return a mapping of instance id to
 instanceInfo objects.
Searches for instances in the provided directory Looks through all sub - dirs of the provided directory for valid instance definitions and return a mapping of instance id to instanceInfo objects .
// Ignore folders without config.json