async function startServer() { const client = await MongoClient.connect('mongodb://localhost:27017/admin', {useNewUrlParser: true}) app.context.torrentdb = client.db('torrent') app.context.mdb = await mysql.createPool({ connectionLimit: 5, host: 'localhost', user: 'root', password: '', port: 9306, multipleStatements: true }) app.listen(process.env.PORT || 3000, async () => { console.log(new Date(), 'Server is istening...') if(process.send) { process.send('ready') } }) }
async function start() { // Instantiate nuxt.js const nuxt = new Nuxt(config) const { host = process.env.HOST || '127.0.0.1', port = process.env.PORT || 3001 } = nuxt.options.server // Build in development if (config.dev) { const builder = new Builder(nuxt) await builder.build() } else { await nuxt.ready() } app.use(ctx => { ctx.status = 200 ctx.respond = false // Bypass Koa's built-in response handling ctx.req.ctx = ctx // This might be useful later on, e.g. in nuxtServerInit or with nuxt-stash nuxt.render(ctx.req, ctx.res) }) app.listen(port, host) consola.ready({ message: `Server listening on http://${host}:${port}`, badge: true }) }
const PORT = process.env.PORT || 4000; const TLS_PORT = process.env.TLS_PORT || 4433;
function setupMiddleware(app) { app.set('port', process.env.PORT || 3000); app.disable('x-powered-by'); app.set('trust proxy', 1); // express behind proxy doesn't receive X-Forwarded-* header, if false. app .use(morgan('dev')) // http logger .use(cors({ origin: [ 'http://localhost:3001' ] })) .use(express.json({limit: '1mb'})) // default application/json. .use(express.urlencoded({extended: true, limit: '1mb'})); // doesn't handle multipart, use multer. // use api routes app.use(`/${process.env.API_VERSION || 1}`, routes); // catch all error. It doesn't handle errors sent by next(). But we don't need it. app.use((req, res, next) => { return errors.notFound(res); }); return app; }
// connect our app to the MongoDB database. app.locals.connect().then(() => { console.log(app.locals.name + ' connected to MongoDB'); // listen to the configured port for incoming requests. // process.env.PORT lets the port be set by Heroku const port = process.env.PORT || app.locals.config.server.port; app.listen(port, function () { console.log(app.locals.name + ' listening on port ' + port); }); }).catch(err => { console.error(err.message); });
SpotSchema .virtual('thumbnail_url') .get(function() { return `http://${process.env.internalIP}:${process.env.PORT}/files/${this.thumbnail}` })
SwaggerExpress.create(config, function(err, swaggerExpress) { if (err) { throw err; } app.use(SwaggerUi(swaggerExpress.runner.swagger)); app.use(swaggerExpress.runner.swaggerTools.swaggerSecurity(config.swaggerSecurityHandlers)); swaggerExpress.register(app); var port = process.env.PORT || 10010; app.listen(port); if (swaggerExpress.runner.swagger.paths['/']) { console.log('Project started.'); } });
app.listen(process.env.PORT || 8080, () => { console.log(`Listening on port: ${server.address().port}`); process.nextTick(() => Server.refresh()); setInterval(() => Server.refresh(), 600000); })
function options() { let options = {}; options.port = process.env.PORT; options.clientDirPath = process.env.CLIENT_DIR || null; options.indexPath = process.env.INDEX || null; options.staticDirPath = process.env.STATIC_DIR || null; return options; }
static start(port, opt) { let app = require("../config/express")(); let PORT = process.env.PORT || port || __config.port; app.listen(PORT); if (opt && opt.debug) { __.logger.info(`Application config information: => Template engine: Nunjucks => Model database: Mongodb => Theme current: Bootstrap\n`); __.logger.info(`=> Listening on port ${PORT}. Process ID: ${process.pid}`); } }
server.listen(process.env.port || process.env.PORT || 3978, function() { console.log(`\n${ server.name } listening to ${ server.url }`); console.log(`\nGet Bot Framework Emulator: https://aka.ms/botframework-emulator`); console.log(`\nTo talk to your bot, open simple-prompt-bot.bot file in the Emulator`); });
app.listen(process.env.PORT || 3000, process.env.HOST || '127.0.0.1', () => { const host = server.address().address; const port = server.address().port; console.log("Application accessible on http://%s:%s".green, host, port); })
app.listen(process.env.PORT || 8080, () => { console.log(`Listening on port: ${server.address().port}`); process.nextTick(() => Server.refresh()); setInterval(() => Server.refresh(), 600000); })