因此,当我在PC机上运行它时,此Discord Bot可以正常运行。但是,当我将其推送到Heroku时,出现以下错误日志。
当我尝试删除render.py
中的“样式” (下面的日志中提到的部分)时,Bot会联机但无法正常工作(当然)。
heroku[worker.1]: Starting process with command python src/main.py
heroku[worker.1]: State changed from starting to up
heroku[worker.1]: Process exited with status 1
heroku[worker.1]: State changed from up to crashed
app[worker.1]: Traceback (most recent call last):
app[worker.1]: File "src/main.py", line 9, in <module>
app[worker.1]: from render import RenderStats
app[worker.1]: File "/app/src/render.py", line 6, in <module>
app[worker.1]: class RenderStats():
app[worker.1]: File "/app/src/render.py", line 29, in RenderStats
app[worker.1]: 'titles': ImageFont.truetype("fonts/MyriadPro-Bold.otf", 10),
app[worker.1]: File "/app/.heroku/python/lib/python3.6/site-packages/PIL/ImageFont.py", line 546, in truetype
app[worker.1]: return freetype(font)
app[worker.1]: File "/app/.heroku/python/lib/python3.6/site-packages/PIL/ImageFont.py", line 543, in freetype
app[worker.1]: return FreeTypeFont(font, size, index, encoding, layout_engine)
app[worker.1]: File "/app/.heroku/python/lib/python3.6/site-packages/PIL/ImageFont.py", line 161, in init
app[worker.1]: font, size, index, encoding, layout_engine=layout_engine
app[worker.1]: OSError: cannot open resource
文件夹结构有问题吗?
答案 0 :(得分:0)
Heroku并非用于托管Discord Bots,但要回答您的问题,可能是Heroku的ephemeral filesystem。正如Heroku解释的here,您可能托管专用的静态文件(例如字体),它们可能会在每天的Herokus cycling上删除。