// Helper to get excludes const getExcludes = (data = [], inverse = false) => _(data) .filter(exclude => _.startsWith(exclude, '!') === inverse) .map(exclude => _.trimStart(exclude, '!')) .uniq() .compact() .value()
_(normalizeRoutes(routes)) // Map redirects to upstreams .map(route => getUpstream(route, normalizeRoutes(routes))) // Remove blank entries .compact() // Parse to lando things .map(route => _.merge({}, url.parse(route.key), {service: route.upstream.split(':')[0]})) // Filter unsupported upstreams .filter(route => _.includes(_.map(supported, 'name'), route.service)) // Merge in port data .map(route => _.merge({}, route, _.find(supported, {name: route.service}))) // Add port to data .map(route => ({service: route.service, config: getProxyMiddlewares(route)})) // Group by service .groupBy('service') // Map to lando proxy config .map((entries, service) => ([service, _.map(entries, 'config')])) // objectify .fromPairs() // Return .value()
// Add all the apps containers to the lando bridge network after the app starts // @NOTE: containers are automatically removed when the app stops app.events.on('post-start', 1, () => { // We assume the lando net exists at this point const landonet = lando.engine.getNetwork(lando.config.networkBridge); // List all our app containers return lando.engine.list({project: app.project}) // Go through each container .map(container => { // Grab from the proxy if we have them const aliases = _(_.get(app, `config.proxy.${container.service}`, [])) .map(entry => _.isString(entry) ? entry : entry.host) .compact() .value(); aliases.push(`${container.service}.${container.app}.internal`); // Sometimes you need to disconnect before you reconnect return landonet.disconnect({Container: container.id, Force: true}) // Only throw non not connected errors .catch(error => { if (!_.includes(error.message, 'is not connected to network lando')) throw error; }) // Connect .then(() => { landonet.connect({Container: container.id, EndpointConfig: {Aliases: aliases}}); app.log.debug('connected %s to the landonet', container.name); }); }); });
return _(cfg.providers) .map(getProvider) .compact() .value();
function getLatestVersion() { var tags = execSync("git tag"); var latest = _(tags).split("\n") .compact() .sort(semver.gt) .last(); console.log("Latest tag is ", latest); return latest; }
function registerInRedis(worker, redisConnection, stats) { return new Promise(function (resolve, reject) { var keyName = "chatUp:chatServer:" + worker._conf.uuid; redisConnection.multi() .hmset(keyName, { host: worker._conf.host, connections: _(worker._workers).map('stats').map('connections').sum(), pubStats: JSON.stringify(_(worker._workers).map('stats').map('channels').flatten().compact().reduce(function (stats, channel) { stats[channel.name] = _.union(stats[channel.name] || [], channel.publishers); return stats; }, {})), subStats: JSON.stringify(stats) }) .pexpire(keyName, worker._conf.expireDelay) .exec(function (err, results) { if (err) { logger.captureError(logger.error('Redis register', { err: err })); return reject(err); } return resolve(); }); }); }
function registerInRedis(worker: ChatWorker, redisConnection: redis.RedisClient, stats:any):Promise<void> { return new Promise<void>(function(resolve, reject) { var keyName = "chatUp:chatServer:" + worker._conf.uuid; redisConnection.multi() .hmset(keyName, { host: worker._conf.host, connections: _(worker._workers).map('stats').map('connections').sum(), pubStats: JSON.stringify(_(worker._workers).map('stats').map('channels').flatten().compact().reduce((stats, channel:any) => { stats[channel.name] = _.union(stats[channel.name] || [], channel.publishers); return stats; }, {})), subStats: JSON.stringify(stats) }) .pexpire(keyName, worker._conf.expireDelay) .exec((err, results) => { if (err) { logger.captureError(logger.error('Redis register', {err})); return reject(err); } return resolve(); }); }); }