const http = require('http');
const path = require('path');


/**
 * http服务启动
 * @param {*} port 
 * @param {*} app 
 */
function httpServerStart(port, app) {
    const server = http.createServer(app);
    app.set('port', port);
    return new Promise((resolve, reject) => {
        server.listen(port);
        server.on('error', (err) => {
            reject(err);
        });
        server.on('listening', () => {
            console.log('http server ready now');
            resolve(server);
        });
    })

}

module.exports.httpServerStart = httpServerStart;