Heroku Discord Bot 离线

Heroku Discord Bot is offline

我在 heroku 上托管一个 discord 聊天机器人,它突然掉线了。我刚开始在 heroku 上托管,所以我不太了解,但是,我尝试了一些简单的事情,比如再次部署一个分支(我连接到 github),但这行不通。

编辑: 这是日志:

在我点击打开应用之前:

2018-07-23T16:54:27.265702+00:00 app[worker.1]: at Function.Module._load (module.js:497:3)

2018-07-23T16:54:27.265704+00:00 app[worker.1]: at Function.Module.runMain (module.js:693:10)

2018-07-23T16:54:27.265705+00:00 app[worker.1]: at startup (bootstrap_node.js:191:16)

2018-07-23T16:54:27.265707+00:00 app[worker.1]: at bootstrap_node.js:612:3

2018-07-23T16:54:27.327613+00:00 heroku[worker.1]: State changed from up to crashed

2018-07-23T16:54:27.310511+00:00 heroku[worker.1]: Process exited with status 1

点击打开应用后:

2018-07-23T16:58:44.866697+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=cratefield.herokuapp.com request_id=b32a5f7d-157e-45a5-805b-8c306140d020 fwd="73.23.238.216" dyno= connect= service= status=503 bytes= protocol=https

2018-07-23T16:58:45.502353+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=cratefield.herokuapp.com request_id=19e6fc48-37ed-48db-87f9-759d704ddb3e fwd="73.23.238.216" dyno= connect= service= status=503 bytes= protocol=https

2018-07-23T16:58:45.552383+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=cratefield.herokuapp.com request_id=bba2456f-50bc-4dbb-bee2-50b36a8caef5 fwd="73.23.238.216" dyno= connect= service= status=503 bytes= protocol=https

2018-07-23T17:01:47.069331+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=cratefield.herokuapp.com request_id=9a098d43-bc46-403a-9ed3-5b701cd720ac fwd="73.23.238.216" dyno= connect= service= status=503 bytes= protocol=https

您的机器人的问题是 Heroku's free plan 让您的应用程序在 30 分钟不活动后进入休眠状态。解决方案是 select 付费计划,以确保您的机器人始终保持活跃。

发生这种情况是因为您使用的是 web 测功机:如果应用程序超过 1 小时不为网站提供服务,测功机就会进入休眠状态。
解决方案是从 web dyno 切换到 worker dyno:这种类型不为网站提供服务(如果你是 运行 一个 Discord 机器人,你不需要它)并且从不睡觉。

进入你的 Procfile 文件并将 web 替换为 worker,它应该如下所示:

worker: npm start //this is the command you use to start your app.

如果你想看一下Heroku article about sleeping apps

我知道已经晚了一年但是对于那些仍然有这个问题的人,你有每月 550 小时(大约 22 天)的限制来使用免费计划托管你的机器人(付费计划没有 运行时限)

这可能是问题所在,您可以查看 heroku 上的通知以找出答案。