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

node.js和Heroku错误:Web进程在启动后60秒内绑定到$端口失败

万勇
2023-03-14

我一直在尝试用heroku制作一个bot,当我部署它时,我得到了这个错误:
Web进程未能在启动60秒内绑定到$port

这是我的index.js:

const discord = require('discord.js');
const bot = new discord.Client();

const token = 'Nzc0MjQxOTAyMzE2MjI0NTIy.X6U69g.sjmAievx3II561tvYfOVy72an1k';

bot.on('ready', () =>{
    console.log('This bot is online');
})

bot.on('message', message=>{
    if(message.content === "im lost"){
        message.channel.send('You should try finding your way through the welcome channel!')
    }
        if(message.content === "i need help"){
        message.channel.send('Check out the bot-help channel!')
    }
})

bot.login(token);

package.json:

{
  "name": "compass",
  "version": "1.0.0",
  "main": "index.js",
  "scripts": {
   "start": "node index.js"
},
  "author": "Alex",
  "license": "ISC",
  "dependencies": {
    "discord.js": "^12.4.1",
    "express": "^4.17.1"
  },
  "devDependencies": {},
  "repository": {
    "type": "git",
    "url": "git+https://github.com/Razdoll/Compass-Host.git"
  },
  "keywords": [],
  "bugs": {
    "url": "https://github.com/Razdoll/Compass-Host/issues"
  },
  "homepage": "https://github.com/Razdoll/Compass-Host#readme",
  "description": ""
}

和heroku日志:

2020-11-07T10:13:06.345403+00:00 heroku[web.1]: State changed from crashed to starting
2020-11-07T10:13:06.144839+00:00 app[api]: Deploy e1a7636b by user alexismastakouris08@gmail.com
2020-11-07T10:13:06.144839+00:00 app[api]: Release v18 created by user alexismastakouris08@gmail.com
2020-11-07T10:13:06.000000+00:00 app[api]: Build succeeded
2020-11-07T10:13:08.924332+00:00 heroku[web.1]: Starting process with command `npm start`
2020-11-07T10:13:11.837311+00:00 app[web.1]: 
2020-11-07T10:13:11.837349+00:00 app[web.1]: > compass@1.0.0 start /app
2020-11-07T10:13:11.837349+00:00 app[web.1]: > node index.js
2020-11-07T10:13:11.837350+00:00 app[web.1]: 
2020-11-07T10:13:12.713528+00:00 app[web.1]: This bot is online
2020-11-07T10:14:09.151016+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2020-11-07T10:14:09.171490+00:00 heroku[web.1]: Stopping process with SIGKILL
2020-11-07T10:14:09.269376+00:00 heroku[web.1]: Process exited with status 137
2020-11-07T10:14:09.322850+00:00 heroku[web.1]: State changed from starting to crashed

共有1个答案

欧阳俊晖
2023-03-14

你在Heroku上设置了一个web dyno,而不是一个worker dyno。不和机器人是工人。

在Heroku应用程序的resources选项卡上,关闭web dyno,并打开一个worker dyno。

 类似资料: