heroku is a tool that allows you to deploy your app to production for free. It's fairly easy to deploy, so it may be out of place after you've experienced deploying on AWS.
On the other hand, there is a caveat because it can be used for free, and the application deployed on heroku will stop after a certain period of time. In that case, if you use the app again, it will start, but be aware that it will take some time to start.
For example, if you deploy LINE BOT on heroku, there will be a short time lag between sending the text and receiving the first reply from Line. It took about 20 to 30 seconds to experience it.
Although the introduction has become long, there are many commands that I frequently used for such heroku and deployment, so I will describe them below as a memorandum.
$ heroku login
It's literally a command to log in to the heroku site. After entering in the terminal, execute with the enter key. When you enter the command, the following will be displayed, so press the enter key again.
heroku: Press any key to open up the browser to login or q to exit:
Then you will be connected to the net and the screen will be displayed automatically. Pressing the word Log in will complete the login to the heroku site, which will also be noted in the terminal.
https://id.heroku.com/login Alternatively, you can log in directly from the above URL.
First, execute the following command to create an application on heroku.
$ heroku create <app name>
You can create an app like heroku just by typing the above command. Let's decide the application name enclosed in <> arbitrarily.
After that, you can manage the app on the heroku site as well.
After creating the app, it's time to deploy. Deployment is completed by entering the following three commands in order. Please be patient as the deployment will take some time.
$ git add .
$ git commit -m "initial commit"
$ git push heroku master
The deployment is now complete.
This is the command that I personally find most convenient.
You can search for the cause of the error and list how heroku behaves in the terminal. The time is also displayed so you can see when and what happened.
$ heroku logs
Use it when you are in trouble.
Environment variables are set to strictly manage unpleasant tokens when leaked to the outside. The following is an assumption when the LINE BOT environment variable is set.
I mistyped the wording and input command in the controller file and got addicted to the error that the token could not be obtained.
So be careful about spelling mistakes and writing mistakes. If you get stuck in an error, look for the cause in the above heroku logs.
$ heroku config:set LINE_BOT_CHANNEL_SECRET="[LINE channel secret]"
$ heroku config:set LINE_BOT_CHANNEL_TOKEN="[LINE access token]"
I think that environment variables are necessary or unnecessary depending on what you create, so please set them appropriately.
This command is used when something goes wrong, such as the behavior of the created application is strange.
$ heroku ps:scale web=1
$ heroku ps
Unnecessary apps can be deleted from the heroku site. However, that alone remains in the remote of git, so it is not enough for deletion work. Therefore, it is certain to enter a dedicated command from the terminal and delete all at once.
$ heroku apps:destroy --app <app name>
After entering the command, you will be asked to enter the app name again for confirmation, so enter the app name again and continue the process to complete the deletion of the app. With this command, you can delete both apps on Heroku and remote repositories at once.
Recommended Posts