运行时应用

时间:2018-12-02 01:07:06

标签: node.js heroku runtime telegram

我可以将heroku用于必须始终运行的nodejs应用程序吗?现在,我想创建没有webhook的电报bot,它必须一直运行。

const TelegramBot = require('node-telegram-bot-api');
const token = 'MY TELEGRAM BOT KEY';
const bot = new TelegramBot(token, {polling: true});

bot.on('message', (msg) => {
    const chatId = msg.chat.id;

    // send a message to the chat acknowledging receipt of their message
    bot.sendMessage(chatId, 'Received your message');
  });

1 个答案:

答案 0 :(得分:0)

是的,在Heroku上部署和运行Node.js应用比我们想象的要容易得多。您可以在Heroku here

上找到有关实时Node.js应用程序的指南。

您必须使用付费计划才能运行实时应用。我们知道免费的Heroku Dyno将在30分钟不活动后进入睡眠状态。在非活动状态下访问我们的应用程序时,我们必须等待几秒钟才能返回活动状态。有关Heroku计划和定价的更多详细信息,请参见here

PS:由于我是初学者,请不要停止我的回答。您可以等待尚未来临的StackOverflow专业用户的解答。或者,如果您愿意,可以在Heroku支持上打开故障单,然后在此处询问您的问题