【发布时间】:2022-01-07 18:44:37
【问题描述】:
所以,我的代码在本地和 docker 映像都可以工作,但是,当我部署到 heroku 时,它似乎在前 1 分钟工作,然后应用程序崩溃,在崩溃后有 heroku logs,那么可能是什么问题?任何想法?谢谢
这是我的代码
const { default: axios } = require('axios')
const telegramBot = require('node-telegram-bot-api')
const express = require('express')
const dotenv = require('dotenv').config()
const links = `
<a href="https://git.foxminded.com.ua/foxstudent100709">GitLab</a>
<a href="https://www.linkedin.com/in/elguja-mtchedlidze-39a746225/">Linkdin</a>
<a href="https://mtchedlidze-87ef7.web.app/">Personal</a>
`
const bot = new telegramBot(process.env.TOKEN, { polling: true })
const aboutText = 'Hello, I am learning NODE JS!'
const app = express()
bot.on('message', (message) => {
const id = message.chat.id
if (message.text === '/start' || message.text === '/help') {
bot.sendMessage(message.chat.id, 'avalable commands', {
reply_markup: {
keyboard: [['/about', '/links']],
resize_keyboard: true,
one_time_keyboard: true,
force_reply: true,
},
})
} else if (message.text === '/about') {
bot.sendMessage(id, aboutText)
} else if (message.text === '/links') {
bot.sendMessage(id, links, { parse_mode: 'HTML' })
} else {
bot.sendMessage(
message.chat.id,
'no such command! there are avalable commands',
{
reply_markup: {
keyboard: [['/about', '/links']],
resize_keyboard: true,
one_time_keyboard: true,
force_reply: true,
},
}
)
}
})
码头文件:
FROM node:16-alpine
WORKDIR /app
COPY package*.json ./
RUN npm install --production
COPY ./app.js .
ENV port=8080
ENV TOKEN=21*****:AAEF******************fKiQ
EXPOSE 8080
CMD [ "node", "app.js" ]
【问题讨论】: