heroku cheat sheet quick start

#note requires java 8. add the ppa repo for oracle and install this if you dont have it already. check your local with: java -version

#create auth token for subsequent commands
heroku login

#from within a local git cloned app root, to create a new dyno
heroku create

#deploy
git push heroku master

#check if dyno is running
heroku ps:scale web=1

#shortcut to open the dyno. if you are running these in a remote SSH you will need to X11 forward for this to work
#or simply, just open the address indicated after you push
#this uri is also visible using the logs command below
heroku open

#tail logs for running dyno. refresh the browser while you are viewing the app to verify new log entries added
heroku logs --tail

#procfile declares what command is executed at start of app. this is likely web.
#for windows: this is different. see heroku docs and make Procfile.windows and use heroku -f Procfile.windows
https://devcenter.heroku.com/articles/procfile

#general note regarding the “free-ness” of heroku on your first app
“By default, your app is deployed on a free dyno. Free dynos will sleep after a half hour of inactivity and they can be active (receiving traffic) for no more than 18 hours a day before going to sleep. If a free dyno is sleeping, and it hasn’t exceeded the 18 hours, any web request will wake it. This causes a delay of a few seconds for the first request upon waking. Subsequent requests will perform normally”

#pom.xml specifies dependencies

#system.properties in the case of java determines version of java to use

#pull in dependencies to target/dependency and store this in pom.xml
mvn clean install

#to start heroku locally
heroku local web

#install add-ons
heroku addons:create papertrail

#list add-ons
heroku addons

#open add-on logs
heroku addons:open papertrail

#test a command on a one-off dyno, e.g. run bash in local dyno
heroku run bash

#set environment variables
heroku config:set ENERGY="20 GeV"

#view environment variables
heroku config

#show database info, e.g. postgres
heroku pg

#run tsql commands
heroku pg:psql

References:
https://devcenter.heroku.com/articles/getting-started-with-java

Advertisement

About Ronnie Diaz

Ronnie Diaz is a software engineer and tech consultant. Ronnie started his career in front-end and back-end development for companies in ecommerce, service industries and remote education. This work transitioned from traditional desktop client-server applications through early cloud development. Software included human resource management and service technician workflows, online retail e-commerce and electronic ordering and fulfillment, IVR customer relational systems, and video streaming remote learning SCORM web applications. Hands on server experience and software performance optimization led to creation of a startup business focused on collocated data center services and continued experience with video streaming hardware and software. This led to a career in Amazon Prime Video where Ronnie is currently employed, building software and systems which stream live sports and events for millions of viewers around the world.

Posted on November 9, 2015, in Programming & Development and tagged , , , , , , , , , , , . Bookmark the permalink. Leave a comment.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: