当前位置: 首页 > 知识库问答 >
问题:

HEROKU和HAPIJS错误R10(引导超时)-> Web进程无法在启动后60秒内绑定到PORT

公西国发
2023-03-14

**HEROKU日志--tail***dasdasdsda HEROKU和HAPIJS错误R10(启动超时)-

    2019-02-10T22:55:41.713305+00:00 heroku[web.1]: State changed from starting to crashed
    2019-02-10T22:55:41.565831+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
    2019-02-10T22:55:41.565970+00:00 heroku[web.1]: Stopping process with SIGKILL
    2019-02-10T22:55:41.695141+00:00 heroku[web.1]: Process exited with status 137

我的服务器启动了。

'use strict';

// Create a server with a host and port
const server=Hapi.server({
    host:'0.0.0.0',
    port: process.env.PORT | 8000
});

// Add the route
server.route({
  method:'GET',
  path:'/hello',
  handler:function(request,h) {

      return'hello world';
  }
});

// Start the server
const start =  async function() {

  try {
      await server.start();
  }
  catch (err) {
      console.log(err);
      process.exit(1);
  }

  console.log('Server running at:', server.info.uri);
};

start();

包JSON

{
  "name": "Fish",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "yarn test",
    "dev": "NODE_ENV=development nodemon server.js",
    "start": "node server.js",
    "deploy": "git add . && git commit -m 'deploy automatitly' && git push heroku master"
  },

  "license": "ISC",
  "dependencies": {
    "boom": "^7.3.0",
    "hapi": "^17.8.4",
    "hapi-server-session": "^4.3.1",
    "hapi-swagger": "^9.3.1",
    "inert": "^5.1.2",
    "joi": "^14.3.1",
    "mongoose": "^5.4.11",
    "rest-hapi": "^1.3.3",
    "vision": "^5.4.4"
  },
  "devDependencies": {
    "nodemon": "^1.18.10"
  },
  "engines": {
    "node": "~8.11.4",
    "npm": "5.6.0"
  }
}

共有1个答案

漆雕嘉平
2023-03-14

创建一个Procfile(无扩展名),并在其中编写app:node“your js for start”。js,然后在设置中使用localhost而不是0.0.0https://dashboard.heroku.com/apps/“您的应用程序”/resources
有滑块在此处输入图像描述

在此处输入图像描述

这对我有效,希望对你也有效。祝你好运)

 类似资料: