Heroku: Difference between revisions
| Line 70: | Line 70: | ||
* check DB connection by | * check DB connection by | ||
C:\Uwes\Programme\PostgreSQL\12\bin> .\[[Postgres#Operation|psql]] -h ec2-3-230-122-20.compute-1.amazonaws.com -U cepxizounlueue defpfuas3qslld | C:\Uwes\Programme\PostgreSQL\12\bin> .\[[Postgres#Operation|psql]] -h ec2-3-230-122-20.compute-1.amazonaws.com -U cepxizounlueue defpfuas3qslld | ||
* set specific configurations for Heroku by adding profile <code>heroku</code> to <code>pom.xml</code> and set config var <code>MAVEN_CUSTOM_OPTS</code> to <code>-P !local_dev,heroku</code> | * set specific configurations for Heroku by adding profile <code>heroku</code> to <code>pom.xml</code> and set config var <code>MAVEN_CUSTOM_OPTS</code> to <code>-P !local_dev,heroku</code> | ||
Revision as of 15:24, 20 July 2022
Installation
Concepts
- all Heroku applications run in a collection of lightweight Linux containers called Dynos. To find out the dynos:
heroku ps
- Procfiles can contain additional process types. For example, you can declare a background worker that processes items off a queue.
- The set of dynos declared in your Procfile and managed by the dyno manager via heroku ps:scale are known as the dyno formation. These dynos do the app’s regular business (such as handling web requests and processing background jobs) as it runs. When you wish to do one-off administrative or maintenance tasks for the app, or execute some task periodically using Heroku Scheduler, you can spin up a one-off dyno.
Interface
- Dashboard login with user, password and Salesforce App on mobile
Config and Environment Variables
- config variables are static and available via
heroku configor via the Heroku Dashboard - environment variables are dynamic and are available via
heroku run env
Add Ons
Databases
- documentation
- connection information see config var DATABASE_URL [database type]://[username]:[password]@[host]:[port]/[database name]
Postgres
- DB info dashboard -> <APPLICATION> -> Resources
Operation
Delete Application
heroku apps:destroy uweheuer-capstone
List all Applications
heroku apps
List all Domains (for Applications)
heroku domains
Logging
- via dasboard
- or via command line
heroku logs --tail
Example
Official Tutorial
PS C:\Temp\python-getting-started> heroku login
- clone example
- create app and push code
- start the app
PS C:\Temp\python-getting-started> heroku ps:scale web=1 Scaling dynos... done, now running web at 1:Free PS C:\Temp\python-getting-started> heroku open // opens https://arcane-peak-78109.herokuapp.com/
- open the dashboard
- stop it or scale it down to 0
heroku ps:scale web=0
- prepare for running locally
PS C:\Temp\python-getting-started> python -m venv venv PS C:\Temp\python-getting-started> .\venv\Scripts\activate (venv) PS C:\Temp\python-getting-started> pip install -r .\requirements.txt
- run it locally
(venv) PS C:\Temp\python-getting-started> python manage.py collectstatic (venv) PS C:\Temp\python-getting-started> heroku local -f .\Procfile.windows
- open it http://localhost:5000/
Spring Boot Demo
Configuration for Heroku
- steps from offical Spring Boot tutorial
- create demo1 application in
C:\Uwes\Programme\eclipse\workspace\demo1and git it - see SpringBoot.docx
- When deploying an app, Heroku reads
pom.xmlfile and installs the dependencies by runningmvn clean install. - check DB connection by
C:\Uwes\Programme\PostgreSQL\12\bin> .\psql -h ec2-3-230-122-20.compute-1.amazonaws.com -U cepxizounlueue defpfuas3qslld
- set specific configurations for Heroku by adding profile
herokutopom.xmland set config varMAVEN_CUSTOM_OPTSto-P !local_dev,heroku
Run on Heroku
git push heroku master heroku open // opens the application https://intense-caverns-96515.herokuapp.com/ in a browser
Prepare Locally Heroku
- create Procfile
Procfile.windowsfor running locally with command to start the Spring applicationjava -jar target/demo1-0.0.1-SNAPSHOT.jar - compile and build a JAR, with dependencies, placing it into your application’s target directory. The
spring-boot-maven-pluginin thepom.xmlprovides this process
mvn install
- create local DB
C:\Uwes\Programme\xampp7.2.27\mysql\bin\mysql --user=root --password=mHalloo0@1m create database demo1;
- create
C:\Uwes\eclipse\workspace_2020-12\SpringBoot\demo1\set_local_dev.bat - add profile local_dev to
pom.xml
Run Heroku Locally
- run the application
set_local_dev.bat // start eclipse by start_eclipse.bat from shell and run it or heroku local -f Procfile.windows
Run Eclipse Locally
- see
src\main\resources\application.propertieswhich is not in Git repository - start eclipse