Skip to content

Instantly share code, notes, and snippets.

@saravanabalagi
Last active July 9, 2018 13:59
Show Gist options
  • Select an option

  • Save saravanabalagi/3bef6df94cdb94445c7f7fb2d14cf47a to your computer and use it in GitHub Desktop.

Select an option

Save saravanabalagi/3bef6df94cdb94445c7f7fb2d14cf47a to your computer and use it in GitHub Desktop.
This snippet shows how to run simple continuously running python scripts on Heroku

Deploying long running python scripts on Heroku

  1. Add Procfile with the following contents
worker: python your_script.py
  1. Add requirements.txt file with the format MODULE_NAME==MODULE_VERSION. Example:
slackclient==1.2.1

Note: Don't add all the requirements using pip freeze as this may create a huge file with so many requirements including conda if you use one, instead pick the ones that are absolutely required

  1. Push code to heroku and it should be successfully deployed
  2. Now we need to run the infinitely listening script on a worker instance
heroku ps:scale worker=1
  1. Check Heroku logs to see outputs such as Listening on ... using
heroku logs --tail
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment