I want to publish the product at the lowest cost

Nice to meet you. This is Taro Man. I usually develop web services.

-** Siltrend **

Introduction

彡 (゜) (゜) "I want to make a ** service ** and publish it ~" 彡 (゜) (゜) "But it's ** trouble ** to rent a rental server ..." 彡 (゜) (゜) "** Server fee ** I don't want to pay ..."

Have you ever felt like this? I'm sure there is.

In that case, use the ** Heroku Free Plan **. In this article, I'll write about how to publish your application on Heroku's free plan.

▷ Heroku official website is here

What can you do with a free plan?

You can do most of the things. You can use it without any problems if you deploy and operate the application on the server.

There are two restrictions to keep in mind with Heroku's free plan:

--Free Dyno hours (operating hours) is 550 hours / month ――The app goes to sleep if there is no access for 30 minutes

Free Dyno hours (uptime) 550 hours / month

If you leave Heroku's free plan at its default, you'll only get 550 hours of Dyno hours a month.

30 days x 24 hours = 720 hours, so if you try to run it at full capacity for a month, the free plan is not enough.

However, this can be solved if you have a ** credit card **.

Even with the free plan, if you register a credit card in your account 450 hours / month of free Dyno hours will be added, allowing you to use up to a total of ** 1,000 hours ** / month.

The app goes to sleep without access for 30 minutes

With the free plan, the app will sleep if there is no access for 30 minutes, The response will be slow ** by the time the app is launched the next time you access it.

However, this can be solved with ** Heroku Scheduler **.

Heroku Scheduler is a feature that allows you to periodically execute specified commands. It's like Linux cron.

By running the ** curl command ** on your app's URL on Heroku Scheduler You can keep running without dropping the app.

▷ How to set up Heroku Scheduler is summarized in this article.

How to deploy to server

1. Installation of required libraries

Install the libraries needed for your project to run on Heroku.

pip install gunicorn django-heroku

2. Add execution environment file

Create a file in ** directly under the project directory ** that tells Heroku the execution environment of the project.

runtime.txt

A file that describes the Python version.

runtime.txt


python-3.6.6

Procfile

This file contains commands to start the Heroku process. Replace <your-project-name> with your own project name.

Procfile


web: gunicorn <your-project-name>.wsgi --log-file -

requirements.txt Here is a list of dependent packages. Let's save the output result of the pip freeze command as it is.

commandline


pip freeze > requirements.txt

3. Modify the project configuration file

Change the DEBUG = Ture part of settings.py for production use.

your-project/settings.py


DEBUG = False

4. Commit with Git

Create & commit a local repository in Git.

python


git init                                
git config user.name "Your Name"        
git config user.email [email protected]   
git add .                            
git commit -m "first commit"     

5. Deploy with Heroku command

Deploy to Heroku with the Heroku command. When you run the heroku login command, your browser will launch and you will be asked to authenticate with Heroku. After logging in, you can go back to the terminal ** without dropping your browser for further work.

python


heroku login
heroku create <your-app-name>
git push heroku master
heroku ps:scale web=1
heroku run python manage.py migrate

at the end

We hope that as many engineers as possible can publish their products to the world.

Recommended Posts

I want to publish the product at the lowest cost
I want to pin Spyder to the taskbar
I want to output to the console coolly
I want to handle the rhyme part1
I want to handle the rhyme part3
I want to display the progress bar
I want to handle the rhyme part2
I want to handle the rhyme part5
I want to handle the rhyme part4
I want to handle the rhyme part7 (BOW)
I want to customize the appearance of zabbix
I want to use the activation function Mish
I want to display the progress in Python!
The story of IPv6 address that I want to keep at a minimum
I want to make a music player and file music at the same time
I want to see the file name from DataLoader
I want to grep the execution result of strace
I want to scroll the Django shift table, but ...
I want to fully understand the basics of Bokeh
I want to write in Python! (3) Utilize the mock
I want to handle the rhyme part6 (organize once)
I want to automate ssh using the expect command!
I tried to simulate the dollar cost averaging method
I want to use the R dataset in python
I want to handle the rhyme part8 (finished once)
I want to increase the security of ssh connections
I want to use Linux commands at the command prompt! Use Linux commands at the command prompt instead of Git Bash
I want to solve Sudoku (Sudoku)
[TensorFlow] I want to master the indexing for Ragged Tensor
I want to use the latest gcc without sudo privileges! !!
I want to initialize if the value is empty (python)
I want to save the photos sent by LINE to S3
I want to move selenium for the time being [for mac]
I want to get the operation information of yahoo route
I want to change the Japanese flag to the Palau flag with Numpy
I want to calculate the allowable downtime from the operating rate
[Python] I want to use the -h option with argparse
I want to judge the authenticity of the elements of numpy array
I want to know the features of Python and pip
I want to make the Dictionary type in the List unique
I want to map the EDINET code and securities number
Keras I want to get the output of any layer !!
I want to align the significant figures in the Numpy array
I want to know the legend of the IT technology world
I want to create a Dockerfile for the time being.
I didn't want to write the AWS key in the program
I want to get information from fstab at the ssh connection destination and execute a command
I want to record the execution time and keep a log.
I want to manually assign the training parameters of the [Pytorch] model
I want to automatically find high-quality parts from the videos I shot
I want to know the weather with LINE bot feat.Heroku + Python
[Linux] I want to know the date when the user logged in
I want to understand systemd roughly
I want to read the html version of "OpenCV-Python Tutorials" OpenCV 3.1 version
I want to output the beginning of the next month with Python
I want to find the shortest route to travel through all points
LINEbot development, I want to check the operation in the local environment
I want to create a system to prevent forgetting to tighten the key 1
I calculated the stochastic integral (I to integral)
I want to automatically answer Google Form at 5 o'clock every morning
I want to make the second line the column name in pandas