简体   繁体   English

在 heroku 上运行多个 python 文件

[英]Running multiple python files on heroku

I have 3 files:我有 3 个文件:

  1. webapp.py => simple flask app that with every GET requests reads stock.txt and shows it content webapp.py => 简单的 flask 应用程序,每个 GET 请求都会读取 stock.txt 并显示其内容

  2. scrapper.py => simple bs4 scrapper that scraps a site every 5 minutes and saves its stock to a file stock.txt scrapper.py => 简单的 bs4 刮板,每 5 分钟刮取一个站点并将其库存保存到文件 stock.txt

  3. stock.txt => stores the stock from scrapper.ppy stock.txt => 存储来自 scrapper.ppy 的股票

I have no problem running it on my local pc but i dont know how to deploy it to heroku我在本地电脑上运行它没有问题,但我不知道如何将它部署到 heroku

I cant find an simple answer on heroku docs我在 heroku 文档上找不到简单的答案

Well you'll find a lot of problems if you are not familiar with Heroku in the first place.好吧,如果您一开始不熟悉 Heroku,就会发现很多问题。

In heroku you have to build your procfile and with this configure your webapp, clock and jobs.在 heroku 中,您必须构建您的 procfile 并以此配置您的 webapp、时钟和作业。

Example Procfile for a web application: web 应用程序的示例Procfile

web: gunicorn webapp:app 

Example Procfile for a clock (scheduled job):时钟的示例Procfile (计划作业):

clock: python scarpper.py

And with the last one you have some serious problem because Heroku have a virtual instance of you code so modifications to your repository files will not be persisted.最后一个你有一些严重的问题,因为 Heroku 有一个你代码的虚拟实例,所以对你的存储库文件的修改不会被持久化。 Maybe think of using a Database.也许考虑使用数据库。

PD: You only need one procfile containing the deployment information. PD:您只需要一个包含部署信息的 procfile。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM