node.js - Swagger running on Heroku: port problems? -
i using nodejs, express, swagger-tools swagger api document showing /docs in heroku dyno. locally works, on heroku port not listening.
app[web.1]: info: swagger-ui available on localhost:5765/docs heroku[web.1]: state changed crashed starting heroku[web.1]: error r10 (boot timeout) -> web process failed bind $port within 60 seconds of launch heroku[web.1]: stopping process sigkill heroku[web.1]: process exited status 137
on code, have port predetermined heroku.
var listen_addr = 'localhost'; var listen_port = process.env.port || 8080; var swaggerdoc = require(options.swaggerui); swaggerdoc.host = listen_addr +":" + listen_port; // making sure of add swaggertools.initializemiddleware(swaggerdoc, function (middleware) { app.use(middleware.swaggermetadata()); app.use(middleware.swaggervalidator()); app.use(middleware.swaggerui() ); app.use(middleware.swaggerrouter(options) ); app.listen(listen_port, listen_addr) { winston.info('server listening on %s:%d', listen, port); winston.info('swagger-ui available on %s:%d/docs', listen, port); }); });
update: problem seemed solved changing app.listen app.listen( process.env.port || 3000, function()
Comments
Post a Comment