Ali*_*Ali 8 deployment heroku node.js
我已经编写了一个基本的node.js应用程序,并且我已经设法在Heroku上部署它而没有任何问题.我已经创建了我的package.json和Procfile,但是从日志中我看到没有正在运行的进程,因此无法获得任何响应.可能是什么问题呢?
PS:我不想使用Express框架
我的代码:
var http = require("http");
http.createServer(function(request, response) {
response.writeHead(200, {"Content-Type": "text/plain"});
response.write("Hello World");
response.end();
console.log("I am working");
}).listen(8888);
Run Code Online (Sandbox Code Playgroud)
我的package.json:
{
"name": "node-example",
"version": "0.0.1",
"dependencies": {
},
"engines": {
"node": "0.8.x",
"npm": "1.1.x"
}
}
Run Code Online (Sandbox Code Playgroud)
日志:
2012-10-22T12:36:58+00:00 heroku[slugc]: Slug compilation started
2012-10-22T12:37:07+00:00 heroku[slugc]: Slug compilation finished
2012-10-22T12:40:55+00:00 heroku[router]: Error H14 (No web processes running) -> GET aqueous-bastion-6914.herokuapp.com/ dyno= queue= wait= service= status=503 bytes=
2012-10-22T12:50:44+00:00 heroku[router]: Error H14 (No web processes running) -> GET aqueous-bastion-6914.herokuapp.com/ dyno= queue= wait= service= status=503 bytes=
Run Code Online (Sandbox Code Playgroud)
J. *_* K. 34
你有没有缩放heroku应用程序?
$ heroku ps:scale web=1
Run Code Online (Sandbox Code Playgroud)
这是必需的步骤.这1是您要为应用程序生成的进程数.
Ins*_*dJW 22
改变你的端口
从
.listen(8888)
Run Code Online (Sandbox Code Playgroud)
至
.listen(process.env.PORT || 8888)
Run Code Online (Sandbox Code Playgroud)