connection .authenticate() .then(() => { console.info('INFO - Database connected.') }) .catch(err => { console.error('ERROR - Unable to connect to the database:', err) })
/* * Ping connection. */ ping() { return Promise.resolve(true); }
// Start listening Promise.fromNode(cb => { api.listen(config.LANDO_API_PORT, cb); }) // Load our routes .then(() => { fs.readdirSync(path.join(__dirname, 'routes')).map(file => { require(`./routes/${file}`)(api, handler, {config, slack}); log.info('Loaded route %s', file); }); log.info('Listening on port: %s', config.LANDO_API_PORT); });
// Helper to get sites for autocomplete const getAutoCompleteSites = (answers, lando, input = null) => { if (!_.isEmpty(pantheonSites)) { return lando.Promise.resolve(pantheonSites).filter(site => _.startsWith(site.name, input)); } else { const api = new PantheonApiClient(answers['pantheon-auth'], lando.log); return api.auth().then(() => api.getSites().map(site => ({name: site.name, value: site.name}))).then(sites => { pantheonSites = sites; return pantheonSites; }); }; }
*parallel(tasks, opts) { try { yield Promise.all(tasks.map(t => this.start(t, opts))); } catch (err) { // } }
bb.coroutine(function * (file, mode) { if (process.platform === "win32") { return true } const info = yield stat(file) return info.isFile() ? Number((info.mode & 0o777).toString(8)) === mode : false })
/* * Insert document into cluster. */ report(data) { const {client, index, type} = this; // Insert document into cluster. return Promise.fromNode(cb => { client.index({index, type, body: data}, cb); }); }
/* * Post new meta data for metrics. */ api.post('/metrics/v2/:id', handler((req, res) => { return Promise.map(plugins, plugin => { const reporter = new plugin.Reporter(config[plugin.config]); return reporter.ping() .then(() => reporter.report(_.merge({}, req.body, {instance: req.params.id}))) .then(() => log.info('Reported to %s', plugin.name)) .then(() => reporter.close()); }); }));
// Bootstrap lando at the correct level lando.bootstrap(bsLevel).then(lando => { // If bootstrap level is APP then we need to get and init our app to generate the app task cache if (bsLevel === 'APP') { lando.getApp().init().then(() => cli.run(bootstrap.getTasks(config, cli.argv()), config)); // Otherwise run as yooz } else { cli.run(bootstrap.getTasks(config, cli.argv()), config); } });
/* * Helper to load in all app plugins */ const loadPlugins = (app, lando) => Promise.resolve(app.plugins.registry) // Filter out .filter(plugin => _.has(plugin, 'app')) // LOADEM! .map(plugin => app.plugins.load(plugin, plugin.app, app, lando)) // Remove any naughty shit .map(plugin => _.pick(plugin.data, ['config', 'composeData', 'env', 'labels'])) // Merge minotaur .each(result => _.merge(app, result))
*serial(tasks, opts) { opts = opts || {}; try { return yield Promise.reduce(tasks, (val, str) => { val && Object.assign(opts, { val }); return this.start(str, opts); }, opts.val || null); } catch (err) { this.emit('serial_error'); } }
*parallel(tasks, opts) { try { yield Promise.all(tasks.map(t => this.start(t, opts))); } catch (err) { // } }
connection .authenticate() .then(() => { console.info('INFO - Database connected.') }) .catch(err => { console.error('ERROR - Unable to connect to the database:', err) })