Giter VIP home page Giter VIP logo

heroku-python-script's Introduction

Template for hosting python scripts and applications on Heroku

This is a small example of running your script with Heroku. You can run almost any python application with any dependencies.

Getting Started

  1. Download or clone this repository

  2. Register on Heroku

  3. Download and install Heroku CLI

  4. Download and install git

  5. Copy your script or project to this repository's folder

  6. Replace "script.py" with the path to your main executable file in Procfile. For details about Procfile refer to the docs. If you need to run web application, you have to use web instead of worker.

  7. You may select your python version and runtime using runtime.txt. Read how on official heroku page.

  8. If you are using any not built-in modules, you must add them to your requirements.txt. To check which version of the module you have, run pip freeze in the terminal. You will get lines with information about installed modules and their versions in the format like MODULE_NAME==MODULE_VERSION. Add lines with required modules and their versions to your requirements.txt. Heroku will install modules from this file automatically.

    If you are using some kind of virtual environment, you can generate ready-to-use requirements.txt with pip freeze > requirements.txt.

  9. Open terminal (or do it another way, but I will explain how to do it in the terminal on Ubuntu) and create a git repository.

    1. Initiate git repository

      git init
    2. Create heroku application

      heroku create
    3. Add, commit and push your code into branch master of the remote heroku.

      git add .
      git commit -m "initial commit"
      git push heroku master
  10. Specify the amount of worker that will run your application

    heroku ps:scale worker=1
  11. Now everything should be working. You can check your logs with this command

    heroku logs --tail
  12. You can open the URL where the script is deployed using the below command (if you are deploying web application)

    heroku open
  13. From now on you can use usual git commands (push, add, commit, etc.) to update your app. Every time you push heroku master your app gets redeployed with updated source code

  14. To stop your application scale down the amount of workers with like this

    heroku ps:scale worker=0

Prerequisites

Authors

Acknowledgments

heroku-python-script's People

Contributors

archanaprabhu avatar josephwegner avatar michaelkryukov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

heroku-python-script's Issues

Do worker dynos not consume dyno hours?

Firstly, thank you for providing this useful repo. I noticed after setting up the program that dyno hours are not being used up by the process. Do only web dynos(and not worker dynos) use dyno hours?

`Worker` should be `web` in Procfile

So, I was developing a simple Telegram bot with Webhooks and your repo came in handy, I appreciate that. But I kept getting "h14" error, despite following all the steps in README. So basically Heroku refused to assign dyno to my process, I tried both heroku ps:scale worker=1 and changing it manually from dashboard. Logs looked like this:
image

Luckily, I found this post, which explained everything. After changing worker to web in my Procfile, bot finally started receiving requests, like this:
image

As you can see, it has nothing to do with the bot itself, because in both cases the app was launched successfully (look at "my comment" in logs).

I am not entirely sure this wasn't my fault, but it looks like it would be a good idea to at least mention web worker type in README.

Code 502 shows what?

herokulogs

I followed your instructions and It was successfully deployed on Heroku. When I run the code " heroku ps:scale worker=1 " and it displayed " Scaling dynos... done, now running worker at 1:Free " and when I enter " heroku logs --tail " I got the logs showing code 502 something... I have taken a screenshot and attached it to this. Please tell me whether my application is running or not. I have scheduled all the tasks at a particular time with a " schedule module " in python code.

not letting me git push

when i run git push heroku master it says the python version is "3.7.3" which is not supported but in runtime.txt i put it to 3.10.8 and made sure to save it but it keeps saying its "3.7.3"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.