我的 Discord 机器人运行良好一段时间,但随后“无法在启动后 60 秒内绑定到 $PORT”

发布于 2025-01-15 20:05:44 字数 1555 浏览 2 评论 0原文

我尝试了不同的方法并查看了所有其他回复,但我不知道如何解决它

错误 R10(启动超时)-> Web 进程未能在启动后 60 秒内绑定到 $PORT 2022-03-19T09:15:18.022903+00:00 heroku[web.1]:使用 SIGKILL 停止进程 2022-03-19T09:15:18.059850+00:00 app[web.1]:等待进程终止时出错:没有子进程 2022-03-19T09:15:18.210022+00:00 heroku[web.1]:进程已退出,状态为 22 2022-03-19T09:15:18.331083+00:00 heroku[web.1]:状态从开始变为

代码崩溃:

require('dotenv').config();
const OpenAI = require('openai-api');
const openai = new OpenAI(process.env.OPENAI_API_KEY);
const { Client, Intents } = require('discord.js');
const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES] });

let prompt =`text here`;

client.on("message", function (message) {
    if (message.author.bot) return;
    prompt += `You: ${message.content}\n`;
    (async () => {
        const gptResponse = await openai.complete({
            engine: 'davinci',
            prompt: prompt,
            maxTokens: 80,
            temperature: 0.7,
            topP: 1,
            presencePenalty: 0,
            frequencyPenalty: 0,
            bestOf: 1,
            n: 1,
            stream: false,
            stop: ['\n', '\n\n']
        });
        message.reply(`${gptResponse.data.choices[0].text.substring(5)}`);
        prompt += `${gptResponse.data.choices[0].text}\n`;
    })();
});     

client.login(process.env.BOT_TOKEN);

我的 procfile 是空的,但它仍然可以工作 60 秒 有什么想法吗? 编辑:我尝试过但不起作用的事情 我尝试更改 procfile 以将

worker:  node index.js

procfile 包含到 worker: java -jar build/libs/*.jar

I've tried different approaches and looked at all the other replies but i dont know how to adress it

Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2022-03-19T09:15:18.022903+00:00 heroku[web.1]: Stopping process with SIGKILL
2022-03-19T09:15:18.059850+00:00 app[web.1]: Error waiting for process to terminate: No child processes
2022-03-19T09:15:18.210022+00:00 heroku[web.1]: Process exited with status 22
2022-03-19T09:15:18.331083+00:00 heroku[web.1]: State changed from starting to crashed

the code:

require('dotenv').config();
const OpenAI = require('openai-api');
const openai = new OpenAI(process.env.OPENAI_API_KEY);
const { Client, Intents } = require('discord.js');
const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES] });

let prompt =`text here`;

client.on("message", function (message) {
    if (message.author.bot) return;
    prompt += `You: ${message.content}\n`;
    (async () => {
        const gptResponse = await openai.complete({
            engine: 'davinci',
            prompt: prompt,
            maxTokens: 80,
            temperature: 0.7,
            topP: 1,
            presencePenalty: 0,
            frequencyPenalty: 0,
            bestOf: 1,
            n: 1,
            stream: false,
            stop: ['\n', '\n\n']
        });
        message.reply(`${gptResponse.data.choices[0].text.substring(5)}`);
        prompt += `${gptResponse.data.choices[0].text}\n`;
    })();
});     

client.login(process.env.BOT_TOKEN);

my procfile is empty but it still works for 60 seconds
any ideas?
edit: THINGS I TRIED THAT DONT WORK
i tried changing procfile to contain

worker:  node index.js

procfile to worker: java -jar build/libs/*.jar

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

红墙和绿瓦 2025-01-22 20:05:44

使用名称 Procfile 而不是 procfile,否则 heroku 不会知道您需要工作进程而不是默认的 Web 进程。

Use the name Procfile instead of procfile, otherwise heroku doesn't learns that you need worker process and not the default web process.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文