Run a Python script on Heroku on schedule (as a separate app) -


ok i'm working on app has 2 heroku apps - 1 writer writes db after scraping site, , 1 reader consumes said db.

the former python script has kind of while 1 loop - it's twitter stream. want run every x minutes independent of reader doing.

now, running script locally works fine, i'm not sure how getting work on heroku work. i've tried looking up, not find solid answer. read background tasks, redis queue, one-off dynos etc, i'm not sure use purpose. of requirements are:

  1. have python script keep logs of whatever want.
  2. in future, might want add admin panel writer, show me stats of script (and logs). hooking admin panel (flask) should easy-ish , not break script itself.

i love suggestions or pointers here.

  1. i suggest writing consumer server waits around, processes stream on timed interval. is, start once , runs forever, doing processing every 10 minutes or so.

    see: sched python module, handles scheduling events @ times , running them.

  2. simpler: use heroku's scheduler service.

this technique simpler -- it's straight-through code -- can lead problems if have 2 of same consumer running @ same time.


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -