Node.js:简单的应用不能在Heroku上工作 [英] Node.js: Simple app not working on Heroku

查看:96
本文介绍了Node.js:简单的应用不能在Heroku上工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编写了一个基本的node.js应用程序,我已经设法在Heroku上部署它,而没有任何问题。我创建了我的 package.json Procfile ,但是从日志中我看到没有正在运行的进程,因此无法得到任何响应。可能是什么问题?



PS:我不想使用 Express 框架



我的代码:

  var http = HTTP); 

http.createServer(function(request,response){
response.writeHead(200,{Content-Type:text / plain});
响应。写(Hello World);
response.end();

console.log(我正在工作);
})listen(8888);

我的package.json:

  {
name:node-example,
version:0.0.1,
dependencies :{
},
engines:{
node:0.8.x,
npm:1.1.x
}
}

日志:

  2012-10-22T12:36:58 + 00:00 heroku [slugc]:Slug汇编开始
2012-10-22T12:37: 07 + 00:00 heroku [slugc]:插头编译完成
2012-10-22T12:40:55 + 00:00 heroku [路由器]:错误H14(没有Web进程运行) - > GET water-bastion-6914.herokuapp.com/ dyno = queue = wait = service = status = 503 bytes =
2012-10-22T12:50:44 + 00:00 heroku [路由器]:错误H14(否web进程运行) - > GET water-bastion-6914.herokuapp.com/ dyno = queue = wait = service = status = 503 bytes =


解决方案

你是否缩放了heroku应用程序?

  $ heroku ps: = 1 

这是必需的步骤。 1 是您希望为您的应用程序生成的进程数。


I've written a basic node.js application and I've managed to deploy it on Heroku without having any problem. I've created my package.json and Procfile, however from logs I see that there is no running processes, thus cannot get any response. What could be the problem?

PS: I do not want to use the Express framework

My Code:

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);

My package.json:

{
  "name": "node-example",
  "version": "0.0.1",
  "dependencies": {
  },
  "engines": {
    "node": "0.8.x",
    "npm": "1.1.x"
  }
}

Logs:

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=

解决方案

Have you scaled the heroku app?

$ heroku ps:scale web=1

This is a required step. The 1 is the number of processes you want spawned for your app.

这篇关于Node.js:简单的应用不能在Heroku上工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆