如何将我的节点js app(实时跟踪)部署到heroku

时间:2018-02-19 09:02:03

标签: node.js heroku

我曾尝试将节点js应用程序部署到heroku。但总会发生应用程序错误..

这是我的网络日志

  

2018-02-19T09:00:51.759639 + 00:00 heroku [web.1]:州改变自   坠毁到开始2018-02-19T09:00:54.029447 + 00:00 heroku [web.1]:   使用命令node index.js启动流程   2018-02-19T09:00:55.992998 + 00:00 app [web.1]:服务器在端口上启动   3000 2018-02-19T09:01:54.487612 + 00:00 heroku [web.1]:错误R10(启动   超时) - > Web进程无法在60秒内绑定到$ PORT   发布2018-02-19T09:01:54.487612 + 00:00 heroku [web.1]:停止   使用SIGKILL的过程2018-02-19T09:01:54.622011 + 00:00 heroku [web.1]:   国家从开始变为崩溃   2018-02-19T09:01:54.608384 + 00:00 heroku [web.1]:进程退出   状态137

并在我的终端中警告说没有找到env文件

这里是更新的日志..

  

2018-02-20T22:33:28.164758 + 00:00 app [web.1]:在Module._compile   (module.js:570:32)2018-02-20T22:33:28.164760 + 00:00 app [web.1]:at   Object.Module._extensions..js(module.js:579:10)   2018-02-20T22:33:28.164761 + 00:00 app [web.1]:在Module.load   (module.js:487:32)2018-02-20T22:33:28.164763 + 00:00 app [web.1]:at   tryModuleLoad(module.js:446:12)2018-02-20T22:33:28.164765 + 00:00   app [web.1]:在Function.Module._load(module.js:438:3)   2018-02-20T22:33:28.164766 + 00:00 app [web.1]:在Module.runMain   (module.js:604:10)2018-02-20T22:33:28.164768 + 00:00 app [web.1]:at   run(bootstrap_node.js:389:7)2018-02-20T22:33:28.164769 + 00:00   app [web.1]:启动时(bootstrap_node.js:149:9)   2018-02-20T22:33:28.164771 + 00:00 app [web.1]:at   bootstrap_node.js:504:3 2018-02-20T22:33:41.623294 + 00:00   heroku [router]:at = error code = H10 desc =" App崩溃"方法= GET   路径=" /"主机= realtime-tracker.herokuapp.com   request_id = f5ccc5ea-8044-454e-95d5-9175b93a4be3 fwd =" 110.54.168.160"   dyno = connect = service = status = 503 bytes = protocol = https   2018-02-20T22:33:42.405421 + 00:00 heroku [router]:at = error code = H10   desc =" App崩溃" method = GET path =" /favicon.ico"   主机= realtime-tracker.herokuapp.com   request_id = 9a88d409-6292-4361-b6ca-057e8b8fd5ad fwd =" 110.54.168.160"   dyno = connect = service = status = 503 bytes = protocol = https Disconnected   来自日志流。可能会发生您没有看到的事件   这里!试图重新连接... 2018-02-20T22:33:28.164758 + 00:00   app [web.1]:在Module._compile(module.js:570:32)   2018-02-20T22:33:28.164760 + 00:00 app [web.1]:at   Object.Module._extensions..js(module.js:579:10)   2018-02-20T22:33:28.164761 + 00:00 app [web.1]:在Module.load   (module.js:487:32)2018-02-20T22:33:28.164763 + 00:00 app [web.1]:at   tryModuleLoad(module.js:446:12)2018-02-20T22:33:28.164765 + 00:00   app [web.1]:在Function.Module._load(module.js:438:3)   2018-02-20T22:33:28.164766 + 00:00 app [web.1]:在Module.runMain   (module.js:604:10)2018-02-20T22:33:28.164768 + 00:00 app [web.1]:at   run(bootstrap_node.js:389:7)2018-02-20T22:33:28.164769 + 00:00   app [web.1]:启动时(bootstrap_node.js:149:9)   2018-02-20T22:33:28.164771 + 00:00 app [web.1]:at   bootstrap_node.js:504:3 2018-02-20T22:33:41.623294 + 00:00   heroku [router]:at = error code = H10 desc =" App崩溃"方法= GET   路径=" /"主机= realtime-tracker.herokuapp.com   request_id = f5ccc5ea-8044-454e-95d5-9175b93a4be3 fwd =" 110.54.168.160"   dyno = connect = service = status = 503 bytes = protocol = https   2018-02-20T22:33:42.405421 + 00:00 heroku [router]:at = error code = H10   desc =" App崩溃" method = GET path =" /favicon.ico"   主机= realtime-tracker.herokuapp.com   request_id = 9a88d409-6292-4361-b6ca-057e8b8fd5ad fwd =" 110.54.168.160"   dyno = connect = service = status = 503 bytes = protocol = https Disconnected   来自日志流。可能会发生您没有看到的事件   这里!试图重新连接... 2018-02-20T22:33:28.164758 + 00:00   app [web.1]:在Module._compile(module.js:570:32)   2018-02-20T22:33:28.164760 + 00:00 app [web.1]:at   Object.Module._extensions..js(module.js:579:10)   2018-02-20T22:33:28.164761 + 00:00 app [web.1]:在Module.load   (module.js:487:32)2018-02-20T22:33:28.164763 + 00:00 app [web.1]:at   tryModuleLoad(module.js:446:12)2018-02-20T22:33:28.164765 + 00:00   app [web.1]:在Function.Module._load(module.js:438:3)   2018-02-20T22:33:28.164766 + 00:00 app [web.1]:在Module.runMain   (module.js:604:10)2018-02-20T22:33:28.164768 + 00:00 app [web.1]:at   run(bootstrap_node.js:389:7)2018-02-20T22:33:28.164769 + 00:00   app [web.1]:启动时(bootstrap_node.js:149:9)   2018-02-20T22:33:28.164771 + 00:00 app [web.1]:at   bootstrap_node.js:504:3 2018-02-20T22:33:41.623294 + 00:00   heroku [router]:at = error code = H10 desc =" App崩溃"方法= GET   路径=" /"主机= realtime-tracker.herokuapp.com   request_id = f5ccc5ea-8044-454e-95d5-9175b93a4be3 fwd =" 110.54.168.160"   dyno = connect = service = status = 503 bytes = protocol = https   2018-02-20T22:33:42.405421 + 00:00 heroku [router]:at = error code = H10   desc =" App崩溃" method = GET path =" /favicon.ico"   主机= realtime-tracker.herokuapp.com   request_id = 9a88d409-6292-4361-b6ca-057e8b8fd5ad fwd =" 110.54.168.160"   dyno = connect = service = status = 503 bytes = protocol = https

1 个答案:

答案 0 :(得分:0)

Heroku动态地为您指定一个端口作为环境变量(PORT)。不要试图强制侦听特定端口,而是使用:

listen(process.env.PORT)