SlideShare a Scribd company logo
HEROKU TIPS AND HACKS
1. Create an account on Heroku.
- Go to website: ​http://heroku.com/
2. Install Heroku toolbelt:​(​https://toolbelt.heroku.com/​)
- It is everything you need to get started using Heroku.
- Install: ​wget -qO- ​https://toolbelt.heroku.com/install-ubuntu.sh​| sh
3. Login to Heroku
- Run: $ heroku login (enter username and password)
- If have errors about ssh key:
http://www.ajibanda.com/2013/02/reset-git-ssh-key-to-log-in-using-a-new-heroku-
account.html
4. Add gem and config asset pipeline :
- In Gemfile:
gem ‘rails_12factor’, group:production
gem ‘thin’
- In config/application.rb:
config.assets.initialize_on_precompile = false
* Remember: Must commit ​Gemfile.lock ​to server to deploy.
* More details: ​https://devcenter.heroku.com/articles/getting-started-with-rails3
5. CLI Heroku: ​$ heroku run <...>
$ heroku run rake db:migrate
$ heroku restart <name_app_heroku>
$heroku open (open website in browser)
$ heroku run rails c
$ heroku run ruby script/imap_processor start
- Dùng cmd: $ heroku run bash
- View list current account: $ heroku accounts
6. Push local project to Heroku
- Git init in local project:
$ git init
- Add host to current git:
$ git remote add <​origin​> <git@heroku/app>
(​git@heroku.com​:bookmanageapp.git)
- Check remote exist or not? :
$ git remote -v
- Add and commit code
- Push code - ​Deploy code
$ git push [hostname] [branch] / $ git push ​origin/heroku​master
7. Cloning Existing Heroku Applications
$ heroku login
$ heroku git:clone -a <my_app>
$ cd my_app
* More details: ​https://devcenter.heroku.com/articles/git-clone-heroku-app
8. Delayed Job
* More details: ​https://devcenter.heroku.com/articles/delayed-job
9. View processes - logs
- View processes:
$ heroku ps
=== delayed (1X): `bundle exec rake jobs:work`
delayed.1: up 2013/11/04 19:38:01 (~ 15h ago)
=== web (1X): `bundle exec thin start -R config.ru -e $RAILS_ENV -p $PORT`
web.1: up 2013/11/05 08:12:55 (~ 2h ago)
- View logs:
$ heroku logs / $ heroku logs --tail
$ heroku logs -p imap.1
$ heroku logs -p web.
- View db info:
$ heroku config
* More details: ​https://devcenter.heroku.com/articles/logging
10. Multi accounts:
- Add account:
$ heroku accounts:add <name> -- auto
- Remove account:
$ heroku accounts:remove <name>
- Using account:
$ heroku accounts:set <name>
* Remember: Config (host) in: ~/.ssh/config
* More details: ​https://github.com/ddollar/heroku-accounts
- Add key: $ heroku keys:add
- Ex: Found the following SSH public keys:
1) id_rsa.pub
2) identity.heroku.app_rails.pub
3) identity.heroku.personal.pub
4) identity.heroku.work.pub
5) ssh-add id_rsa.pub
Which would you like to use with your Heroku account? => ​3
*More details: ​https://devcenter.heroku.com/articles/keys
11. Config timeout:
https://github.com/heroku/rack-timeout
http://www.rubydoc.info/gems/rack-timeout/0.0.4/frames
12. Access to db postgres on Heroku
- Click to Heroku Postgres Dev on website Heroku application.
- In this page, content some info:
Host : host_path (ec2-123-321-333.compute-00.compute-1.amazonaws.com)
Database: db_name_pg
User: user_name
Password: password
- Connect to database:
$ psql -U <username> -h <host> -d <database>
$ psql -U user_name -h host_path -d db_name_pg
13. View Memory (RAM), CPU, Core based on dyno sizes:
Dyno 
Size 
Memory 
(RAM) 
CPU 
Share 
Multitenan
t 
Compute 
(​2​) 
Price/dyno­hou
r 
1X  512MB  1x  yes  1x­4x  $0.05 
2X  1024MB  2x  yes  4x­8x  $0.10 
PX  6GB  100% (1)  no  40x 
$0.80 
 
*More details:​https://devcenter.heroku.com/articles/dyno-size#available-dyno-sizes
14. Config Domain:
- Add domain:
$ heroku domain add: <example.com>
or add in ​Setting ​section on heroku website.
- Get domain default on heroku: http://<my_app>.heroku.com
Ex: ​http://my_app.herokuapp.com
- Get IP of above domain:
$ host ​my_app.herokuapp.com
=> my_app.herokuapp.com has address ​23.23.80.206
- Go to Godaddy or others service, config your domain point to this IP.
More details: ​https://devcenter.heroku.com/articles/custom-domains
15. Upgrade Mongolab ​(From sandbox-free to Single Node SM)
Changing to or from a single-node plan on Heroku:
1. Stop your app and any other processes writing to your database
2. Backup your database using mongodump
3. Remove your existing add-on
4. Add a new add-on (see available plans ​here​)
5. Restore your database using mongorestore
6. Change your connection string info in your app
7. Restart your app
Example:
$ ​mongodump ​-h ds0123456.mongolab.com:3000 -d heroku_app -u user -p password -o .
$ heroku addons:remove mongolab
$ heroku addons:add mongolab:shared-single-small
$ ​mongorestore​-h <new_host>:<new_port> -d heroku_app -u user -p <​new_password​> .
* Get ​<​new_password​>:
Run :
$ ​heroku config | grep MONGOLAB_URI
Output:
mongodb://heroku_app:​new_password​@​ds0123456​.mongolab.com:3000/heroku_app
Compare with:
​mongodb://<dbuser>:<​dbpassword​>@​ds0123456​.mongolab.com:3000/<dbname>
Informations account :
dbuser: ​dbpassword
dbpassword: ​new_password
dbname: ​heroku_app
* More details: ​https://devcenter.heroku.com/articles/mongolab
16. Improve performance with Unicorn (Concurrency)
-​​Add Gem:
gem ‘unicorn’
- Config:
Create a file configuration for Unicorn at config/unicorn.rb
- When using mongoid:
worker_processes Integer(ENV["WEB_CONCURRENCY"] || 3)
timeout 30
preload_app true
before_fork do |server, worker|
puts worker
end
after_fork do |server, worker|
puts worker
end
If using Mongoid, you don't need to manually reconnect as in the gist. Mongoid claims:
"When using Unicorn or Passenger, each time a child process is forked when using
app preloading or smart spawning, Mongoid will automatically reconnect to the
master database. If you are doing this in your application manually you may remove
your code." (​http://mongoid.org/en/mongoid/docs/rails.html​)
* More details:​​https://devcenter.heroku.com/articles/rails-unicorn
Other references:
http://railsapps.github.io/rails-heroku-tutorial.html
https://devcenter.heroku.com/articles/getting-started-with-rails3
* Developer: ​Nguyễn Thành Luân

More Related Content

What's hot

Mojolicious. Веб в коробке!
Mojolicious. Веб в коробке!Mojolicious. Веб в коробке!
Mojolicious. Веб в коробке!
Anatoly Sharifulin
 
Drupal Day 2012 - Automating Drupal Development: Make!les, Features and Beyond
Drupal Day 2012 - Automating Drupal Development: Make!les, Features and BeyondDrupal Day 2012 - Automating Drupal Development: Make!les, Features and Beyond
Drupal Day 2012 - Automating Drupal Development: Make!les, Features and Beyond
DrupalDay
 
Perl web frameworks
Perl web frameworksPerl web frameworks
Perl web frameworksdiego_k
 
MeaNstack on Docker
MeaNstack on DockerMeaNstack on Docker
MeaNstack on Docker
Daniel Ku
 
Mojo as a_client
Mojo as a_clientMojo as a_client
Mojo as a_client
Marcus Ramberg
 
Devsumi2012 攻めの運用の極意
Devsumi2012 攻めの運用の極意Devsumi2012 攻めの運用の極意
Devsumi2012 攻めの運用の極意Ryosuke IWANAGA
 
How to create a secured multi tenancy for clustered ML with JupyterHub
How to create a secured multi tenancy for clustered ML with JupyterHubHow to create a secured multi tenancy for clustered ML with JupyterHub
How to create a secured multi tenancy for clustered ML with JupyterHub
Tiago Simões
 
How to go the extra mile on monitoring
How to go the extra mile on monitoringHow to go the extra mile on monitoring
How to go the extra mile on monitoring
Tiago Simões
 
Hacking ansible
Hacking ansibleHacking ansible
Hacking ansible
bcoca
 
Installing odoo v8 from github
Installing odoo v8 from githubInstalling odoo v8 from github
Installing odoo v8 from github
Antony Gitomeh
 
Mojolicious - Perl Framework for the Real-Time Web (Lightning Talk)
Mojolicious - Perl Framework for the Real-Time Web (Lightning Talk)Mojolicious - Perl Framework for the Real-Time Web (Lightning Talk)
Mojolicious - Perl Framework for the Real-Time Web (Lightning Talk)
Dotan Dimet
 
PuppetCamp SEA 1 - Version Control with Puppet
PuppetCamp SEA 1 - Version Control with PuppetPuppetCamp SEA 1 - Version Control with Puppet
PuppetCamp SEA 1 - Version Control with Puppet
Walter Heck
 
Using docker for data science - part 2
Using docker for data science - part 2Using docker for data science - part 2
Using docker for data science - part 2
Calvin Giles
 
Ansibleではじめるサーバー・ネットワークの自動化(2019/02版)
Ansibleではじめるサーバー・ネットワークの自動化(2019/02版)Ansibleではじめるサーバー・ネットワークの自動化(2019/02版)
Ansibleではじめるサーバー・ネットワークの自動化(2019/02版)
akira6592
 
Django osc2018-okinawa
Django osc2018-okinawaDjango osc2018-okinawa
Django osc2018-okinawa
Xoxzo Inc.
 
How to Install Odoo 11 on Ubuntu 16.04?
How to Install Odoo 11 on Ubuntu 16.04?How to Install Odoo 11 on Ubuntu 16.04?
How to Install Odoo 11 on Ubuntu 16.04?
Celine George
 
Webrtc mojo
Webrtc mojoWebrtc mojo
Webrtc mojo
bpmedley
 
Phpne august-2012-symfony-components-friends
Phpne august-2012-symfony-components-friendsPhpne august-2012-symfony-components-friends
Phpne august-2012-symfony-components-friendsMichael Peacock
 

What's hot (20)

Mojolicious. Веб в коробке!
Mojolicious. Веб в коробке!Mojolicious. Веб в коробке!
Mojolicious. Веб в коробке!
 
EC2
EC2EC2
EC2
 
Drupal Day 2012 - Automating Drupal Development: Make!les, Features and Beyond
Drupal Day 2012 - Automating Drupal Development: Make!les, Features and BeyondDrupal Day 2012 - Automating Drupal Development: Make!les, Features and Beyond
Drupal Day 2012 - Automating Drupal Development: Make!les, Features and Beyond
 
Perl web frameworks
Perl web frameworksPerl web frameworks
Perl web frameworks
 
MeaNstack on Docker
MeaNstack on DockerMeaNstack on Docker
MeaNstack on Docker
 
Mojolicious
MojoliciousMojolicious
Mojolicious
 
Mojo as a_client
Mojo as a_clientMojo as a_client
Mojo as a_client
 
Devsumi2012 攻めの運用の極意
Devsumi2012 攻めの運用の極意Devsumi2012 攻めの運用の極意
Devsumi2012 攻めの運用の極意
 
How to create a secured multi tenancy for clustered ML with JupyterHub
How to create a secured multi tenancy for clustered ML with JupyterHubHow to create a secured multi tenancy for clustered ML with JupyterHub
How to create a secured multi tenancy for clustered ML with JupyterHub
 
How to go the extra mile on monitoring
How to go the extra mile on monitoringHow to go the extra mile on monitoring
How to go the extra mile on monitoring
 
Hacking ansible
Hacking ansibleHacking ansible
Hacking ansible
 
Installing odoo v8 from github
Installing odoo v8 from githubInstalling odoo v8 from github
Installing odoo v8 from github
 
Mojolicious - Perl Framework for the Real-Time Web (Lightning Talk)
Mojolicious - Perl Framework for the Real-Time Web (Lightning Talk)Mojolicious - Perl Framework for the Real-Time Web (Lightning Talk)
Mojolicious - Perl Framework for the Real-Time Web (Lightning Talk)
 
PuppetCamp SEA 1 - Version Control with Puppet
PuppetCamp SEA 1 - Version Control with PuppetPuppetCamp SEA 1 - Version Control with Puppet
PuppetCamp SEA 1 - Version Control with Puppet
 
Using docker for data science - part 2
Using docker for data science - part 2Using docker for data science - part 2
Using docker for data science - part 2
 
Ansibleではじめるサーバー・ネットワークの自動化(2019/02版)
Ansibleではじめるサーバー・ネットワークの自動化(2019/02版)Ansibleではじめるサーバー・ネットワークの自動化(2019/02版)
Ansibleではじめるサーバー・ネットワークの自動化(2019/02版)
 
Django osc2018-okinawa
Django osc2018-okinawaDjango osc2018-okinawa
Django osc2018-okinawa
 
How to Install Odoo 11 on Ubuntu 16.04?
How to Install Odoo 11 on Ubuntu 16.04?How to Install Odoo 11 on Ubuntu 16.04?
How to Install Odoo 11 on Ubuntu 16.04?
 
Webrtc mojo
Webrtc mojoWebrtc mojo
Webrtc mojo
 
Phpne august-2012-symfony-components-friends
Phpne august-2012-symfony-components-friendsPhpne august-2012-symfony-components-friends
Phpne august-2012-symfony-components-friends
 

Viewers also liked

Taking care of your voice
Taking care of your voiceTaking care of your voice
Taking care of your voiceCarrie Aralis
 
Bootstrap Tutorial
Bootstrap Tutorial Bootstrap Tutorial
Bootstrap Tutorial
Luan Nguyen
 
11108119李芳靜
11108119李芳靜11108119李芳靜
11108119李芳靜靜 李
 
Development banking of mexico
Development banking of mexicoDevelopment banking of mexico
Development banking of mexicoAnjulli Martinez
 
COMU2002: Google+
COMU2002: Google+COMU2002: Google+
COMU2002: Google+
Vera
 
COMU3222 (Part 1)
COMU3222 (Part 1)COMU3222 (Part 1)
COMU3222 (Part 1)
Vera
 
COMU3222 (Part 2)
COMU3222 (Part 2)COMU3222 (Part 2)
COMU3222 (Part 2)
Vera
 
Facebook
FacebookFacebook
Facebook
Vera
 
Conflitti tra studenti: Come affrontarli con la Comunicazione NonViolenta
Conflitti tra studenti: Come affrontarli con la Comunicazione NonViolentaConflitti tra studenti: Come affrontarli con la Comunicazione NonViolenta
Conflitti tra studenti: Come affrontarli con la Comunicazione NonViolenta
Cezar de Costa
 
Slausen Presentation
Slausen PresentationSlausen Presentation
Slausen Presentation
Mary Pirrello
 
COMU1000 Text Analysis
COMU1000 Text AnalysisCOMU1000 Text Analysis
COMU1000 Text Analysis
Vera
 
Perfeccionamiento museo andino valle del maipo
Perfeccionamiento museo andino   valle del maipoPerfeccionamiento museo andino   valle del maipo
Perfeccionamiento museo andino valle del maipoRamon Cortes
 
Euthanasia and Religion in the Media
Euthanasia and Religion in the MediaEuthanasia and Religion in the Media
Euthanasia and Religion in the Media
Vera
 

Viewers also liked (17)

Taking care of your voice
Taking care of your voiceTaking care of your voice
Taking care of your voice
 
Tugas spesalite obat
Tugas spesalite obatTugas spesalite obat
Tugas spesalite obat
 
Bootstrap Tutorial
Bootstrap Tutorial Bootstrap Tutorial
Bootstrap Tutorial
 
Hsp bm sk_y1a
Hsp bm sk_y1aHsp bm sk_y1a
Hsp bm sk_y1a
 
11108119李芳靜
11108119李芳靜11108119李芳靜
11108119李芳靜
 
Hsp bm sk_y1d
Hsp bm sk_y1dHsp bm sk_y1d
Hsp bm sk_y1d
 
Development banking of mexico
Development banking of mexicoDevelopment banking of mexico
Development banking of mexico
 
COMU2002: Google+
COMU2002: Google+COMU2002: Google+
COMU2002: Google+
 
COMU3222 (Part 1)
COMU3222 (Part 1)COMU3222 (Part 1)
COMU3222 (Part 1)
 
COMU3222 (Part 2)
COMU3222 (Part 2)COMU3222 (Part 2)
COMU3222 (Part 2)
 
Facebook
FacebookFacebook
Facebook
 
Conflitti tra studenti: Come affrontarli con la Comunicazione NonViolenta
Conflitti tra studenti: Come affrontarli con la Comunicazione NonViolentaConflitti tra studenti: Come affrontarli con la Comunicazione NonViolenta
Conflitti tra studenti: Come affrontarli con la Comunicazione NonViolenta
 
Slausen Presentation
Slausen PresentationSlausen Presentation
Slausen Presentation
 
COMU1000 Text Analysis
COMU1000 Text AnalysisCOMU1000 Text Analysis
COMU1000 Text Analysis
 
Perfeccionamiento museo andino valle del maipo
Perfeccionamiento museo andino   valle del maipoPerfeccionamiento museo andino   valle del maipo
Perfeccionamiento museo andino valle del maipo
 
Gala 8°b 2014
Gala 8°b 2014Gala 8°b 2014
Gala 8°b 2014
 
Euthanasia and Religion in the Media
Euthanasia and Religion in the MediaEuthanasia and Religion in the Media
Euthanasia and Religion in the Media
 

Similar to Heroku Tips and Hacks

Automating Drupal Development: Makefiles, features and beyond
Automating Drupal Development: Makefiles, features and beyondAutomating Drupal Development: Makefiles, features and beyond
Automating Drupal Development: Makefiles, features and beyondNuvole
 
Хокку про Heroku
Хокку про HerokuХокку про Heroku
Хокку про HerokuGeeksLab Odessa
 
Python from zero to hero (Twitter Explorer)
Python from zero to hero (Twitter Explorer)Python from zero to hero (Twitter Explorer)
Python from zero to hero (Twitter Explorer)
Yuriy Senko
 
2012 coscup - Build your PHP application on Heroku
2012 coscup - Build your PHP application on Heroku2012 coscup - Build your PHP application on Heroku
2012 coscup - Build your PHP application on Herokuronnywang_tw
 
How To Build and Run Node Apps with Docker and Compose
How To Build and Run Node Apps with Docker and ComposeHow To Build and Run Node Apps with Docker and Compose
How To Build and Run Node Apps with Docker and Compose
Docker, Inc.
 
Capifony. Minsk PHP MeetUp #11
Capifony. Minsk PHP MeetUp #11Capifony. Minsk PHP MeetUp #11
Capifony. Minsk PHP MeetUp #11
Yury Pliashkou
 
Infrastructure = code - 1 year later
Infrastructure = code - 1 year laterInfrastructure = code - 1 year later
Infrastructure = code - 1 year later
Christian Ortner
 
2017-03-11 02 Денис Нелюбин. Docker & Ansible - лучшие друзья DevOps
2017-03-11 02 Денис Нелюбин. Docker & Ansible - лучшие друзья DevOps2017-03-11 02 Денис Нелюбин. Docker & Ansible - лучшие друзья DevOps
2017-03-11 02 Денис Нелюбин. Docker & Ansible - лучшие друзья DevOps
Омские ИТ-субботники
 
Building and Customizing CoreOS
Building and Customizing CoreOSBuilding and Customizing CoreOS
Building and Customizing CoreOS
雄也 日下部
 
Big query - Command line tools and Tips - (MOSG)
Big query - Command line tools and Tips - (MOSG)Big query - Command line tools and Tips - (MOSG)
Big query - Command line tools and Tips - (MOSG)
Soshi Nemoto
 
Magento 2 Development
Magento 2 DevelopmentMagento 2 Development
Magento 2 Development
Duke Dao
 
Stackato Presentation Techzone 2013
Stackato Presentation Techzone 2013Stackato Presentation Techzone 2013
Stackato Presentation Techzone 2013
Martin Kenneth Michalsky
 
Simple docker hosting in FIWARE Lab
Simple docker hosting in FIWARE LabSimple docker hosting in FIWARE Lab
Simple docker hosting in FIWARE Lab
Fernando Lopez Aguilar
 
Install Oracle 12c Golden Gate On Oracle Linux
Install Oracle 12c Golden Gate On Oracle LinuxInstall Oracle 12c Golden Gate On Oracle Linux
Install Oracle 12c Golden Gate On Oracle Linux
Arun Sharma
 
Hadoop installation on windows
Hadoop installation on windows Hadoop installation on windows
Hadoop installation on windows
habeebulla g
 
Deploying WP Multisite to Heroku
Deploying WP Multisite to HerokuDeploying WP Multisite to Heroku
Deploying WP Multisite to Heroku
Jussi Kinnula
 
[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview
[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview
[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview
Leo Lorieri
 
Quick and Dirty Python Deployments with Heroku
Quick and Dirty Python Deployments with HerokuQuick and Dirty Python Deployments with Heroku
Quick and Dirty Python Deployments with Heroku
Daniel Pritchett
 
Install and configure linux
Install and configure linuxInstall and configure linux
Install and configure linux
Vicent Selfa
 
Dexterity in 15 minutes or less
Dexterity in 15 minutes or lessDexterity in 15 minutes or less
Dexterity in 15 minutes or less
rijk.stofberg
 

Similar to Heroku Tips and Hacks (20)

Automating Drupal Development: Makefiles, features and beyond
Automating Drupal Development: Makefiles, features and beyondAutomating Drupal Development: Makefiles, features and beyond
Automating Drupal Development: Makefiles, features and beyond
 
Хокку про Heroku
Хокку про HerokuХокку про Heroku
Хокку про Heroku
 
Python from zero to hero (Twitter Explorer)
Python from zero to hero (Twitter Explorer)Python from zero to hero (Twitter Explorer)
Python from zero to hero (Twitter Explorer)
 
2012 coscup - Build your PHP application on Heroku
2012 coscup - Build your PHP application on Heroku2012 coscup - Build your PHP application on Heroku
2012 coscup - Build your PHP application on Heroku
 
How To Build and Run Node Apps with Docker and Compose
How To Build and Run Node Apps with Docker and ComposeHow To Build and Run Node Apps with Docker and Compose
How To Build and Run Node Apps with Docker and Compose
 
Capifony. Minsk PHP MeetUp #11
Capifony. Minsk PHP MeetUp #11Capifony. Minsk PHP MeetUp #11
Capifony. Minsk PHP MeetUp #11
 
Infrastructure = code - 1 year later
Infrastructure = code - 1 year laterInfrastructure = code - 1 year later
Infrastructure = code - 1 year later
 
2017-03-11 02 Денис Нелюбин. Docker & Ansible - лучшие друзья DevOps
2017-03-11 02 Денис Нелюбин. Docker & Ansible - лучшие друзья DevOps2017-03-11 02 Денис Нелюбин. Docker & Ansible - лучшие друзья DevOps
2017-03-11 02 Денис Нелюбин. Docker & Ansible - лучшие друзья DevOps
 
Building and Customizing CoreOS
Building and Customizing CoreOSBuilding and Customizing CoreOS
Building and Customizing CoreOS
 
Big query - Command line tools and Tips - (MOSG)
Big query - Command line tools and Tips - (MOSG)Big query - Command line tools and Tips - (MOSG)
Big query - Command line tools and Tips - (MOSG)
 
Magento 2 Development
Magento 2 DevelopmentMagento 2 Development
Magento 2 Development
 
Stackato Presentation Techzone 2013
Stackato Presentation Techzone 2013Stackato Presentation Techzone 2013
Stackato Presentation Techzone 2013
 
Simple docker hosting in FIWARE Lab
Simple docker hosting in FIWARE LabSimple docker hosting in FIWARE Lab
Simple docker hosting in FIWARE Lab
 
Install Oracle 12c Golden Gate On Oracle Linux
Install Oracle 12c Golden Gate On Oracle LinuxInstall Oracle 12c Golden Gate On Oracle Linux
Install Oracle 12c Golden Gate On Oracle Linux
 
Hadoop installation on windows
Hadoop installation on windows Hadoop installation on windows
Hadoop installation on windows
 
Deploying WP Multisite to Heroku
Deploying WP Multisite to HerokuDeploying WP Multisite to Heroku
Deploying WP Multisite to Heroku
 
[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview
[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview
[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview
 
Quick and Dirty Python Deployments with Heroku
Quick and Dirty Python Deployments with HerokuQuick and Dirty Python Deployments with Heroku
Quick and Dirty Python Deployments with Heroku
 
Install and configure linux
Install and configure linuxInstall and configure linux
Install and configure linux
 
Dexterity in 15 minutes or less
Dexterity in 15 minutes or lessDexterity in 15 minutes or less
Dexterity in 15 minutes or less
 

Recently uploaded

LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
Product School
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
Frank van Harmelen
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
RTTS
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 

Recently uploaded (20)

LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 

Heroku Tips and Hacks

  • 1. HEROKU TIPS AND HACKS 1. Create an account on Heroku. - Go to website: ​http://heroku.com/ 2. Install Heroku toolbelt:​(​https://toolbelt.heroku.com/​) - It is everything you need to get started using Heroku. - Install: ​wget -qO- ​https://toolbelt.heroku.com/install-ubuntu.sh​| sh 3. Login to Heroku - Run: $ heroku login (enter username and password) - If have errors about ssh key: http://www.ajibanda.com/2013/02/reset-git-ssh-key-to-log-in-using-a-new-heroku- account.html 4. Add gem and config asset pipeline : - In Gemfile: gem ‘rails_12factor’, group:production gem ‘thin’ - In config/application.rb: config.assets.initialize_on_precompile = false * Remember: Must commit ​Gemfile.lock ​to server to deploy. * More details: ​https://devcenter.heroku.com/articles/getting-started-with-rails3 5. CLI Heroku: ​$ heroku run <...> $ heroku run rake db:migrate $ heroku restart <name_app_heroku> $heroku open (open website in browser) $ heroku run rails c $ heroku run ruby script/imap_processor start
  • 2. - Dùng cmd: $ heroku run bash - View list current account: $ heroku accounts 6. Push local project to Heroku - Git init in local project: $ git init - Add host to current git: $ git remote add <​origin​> <git@heroku/app> (​git@heroku.com​:bookmanageapp.git) - Check remote exist or not? : $ git remote -v - Add and commit code - Push code - ​Deploy code $ git push [hostname] [branch] / $ git push ​origin/heroku​master 7. Cloning Existing Heroku Applications $ heroku login $ heroku git:clone -a <my_app> $ cd my_app * More details: ​https://devcenter.heroku.com/articles/git-clone-heroku-app 8. Delayed Job * More details: ​https://devcenter.heroku.com/articles/delayed-job 9. View processes - logs - View processes: $ heroku ps === delayed (1X): `bundle exec rake jobs:work` delayed.1: up 2013/11/04 19:38:01 (~ 15h ago) === web (1X): `bundle exec thin start -R config.ru -e $RAILS_ENV -p $PORT` web.1: up 2013/11/05 08:12:55 (~ 2h ago)
  • 3. - View logs: $ heroku logs / $ heroku logs --tail $ heroku logs -p imap.1 $ heroku logs -p web. - View db info: $ heroku config * More details: ​https://devcenter.heroku.com/articles/logging 10. Multi accounts: - Add account: $ heroku accounts:add <name> -- auto - Remove account: $ heroku accounts:remove <name> - Using account: $ heroku accounts:set <name> * Remember: Config (host) in: ~/.ssh/config * More details: ​https://github.com/ddollar/heroku-accounts - Add key: $ heroku keys:add - Ex: Found the following SSH public keys: 1) id_rsa.pub 2) identity.heroku.app_rails.pub 3) identity.heroku.personal.pub 4) identity.heroku.work.pub 5) ssh-add id_rsa.pub Which would you like to use with your Heroku account? => ​3 *More details: ​https://devcenter.heroku.com/articles/keys 11. Config timeout: https://github.com/heroku/rack-timeout http://www.rubydoc.info/gems/rack-timeout/0.0.4/frames
  • 4. 12. Access to db postgres on Heroku - Click to Heroku Postgres Dev on website Heroku application. - In this page, content some info: Host : host_path (ec2-123-321-333.compute-00.compute-1.amazonaws.com) Database: db_name_pg User: user_name Password: password - Connect to database: $ psql -U <username> -h <host> -d <database> $ psql -U user_name -h host_path -d db_name_pg 13. View Memory (RAM), CPU, Core based on dyno sizes: Dyno  Size  Memory  (RAM)  CPU  Share  Multitenan t  Compute  (​2​)  Price/dyno­hou r  1X  512MB  1x  yes  1x­4x  $0.05  2X  1024MB  2x  yes  4x­8x  $0.10  PX  6GB  100% (1)  no  40x  $0.80    *More details:​https://devcenter.heroku.com/articles/dyno-size#available-dyno-sizes 14. Config Domain: - Add domain: $ heroku domain add: <example.com> or add in ​Setting ​section on heroku website.
  • 5. - Get domain default on heroku: http://<my_app>.heroku.com Ex: ​http://my_app.herokuapp.com - Get IP of above domain: $ host ​my_app.herokuapp.com => my_app.herokuapp.com has address ​23.23.80.206 - Go to Godaddy or others service, config your domain point to this IP. More details: ​https://devcenter.heroku.com/articles/custom-domains 15. Upgrade Mongolab ​(From sandbox-free to Single Node SM) Changing to or from a single-node plan on Heroku: 1. Stop your app and any other processes writing to your database 2. Backup your database using mongodump 3. Remove your existing add-on 4. Add a new add-on (see available plans ​here​) 5. Restore your database using mongorestore 6. Change your connection string info in your app 7. Restart your app Example: $ ​mongodump ​-h ds0123456.mongolab.com:3000 -d heroku_app -u user -p password -o . $ heroku addons:remove mongolab $ heroku addons:add mongolab:shared-single-small $ ​mongorestore​-h <new_host>:<new_port> -d heroku_app -u user -p <​new_password​> . * Get ​<​new_password​>: Run : $ ​heroku config | grep MONGOLAB_URI Output: mongodb://heroku_app:​new_password​@​ds0123456​.mongolab.com:3000/heroku_app Compare with: ​mongodb://<dbuser>:<​dbpassword​>@​ds0123456​.mongolab.com:3000/<dbname> Informations account : dbuser: ​dbpassword dbpassword: ​new_password dbname: ​heroku_app * More details: ​https://devcenter.heroku.com/articles/mongolab
  • 6. 16. Improve performance with Unicorn (Concurrency) -​​Add Gem: gem ‘unicorn’ - Config: Create a file configuration for Unicorn at config/unicorn.rb - When using mongoid: worker_processes Integer(ENV["WEB_CONCURRENCY"] || 3) timeout 30 preload_app true before_fork do |server, worker| puts worker end after_fork do |server, worker| puts worker end If using Mongoid, you don't need to manually reconnect as in the gist. Mongoid claims: "When using Unicorn or Passenger, each time a child process is forked when using app preloading or smart spawning, Mongoid will automatically reconnect to the master database. If you are doing this in your application manually you may remove your code." (​http://mongoid.org/en/mongoid/docs/rails.html​) * More details:​​https://devcenter.heroku.com/articles/rails-unicorn Other references: http://railsapps.github.io/rails-heroku-tutorial.html https://devcenter.heroku.com/articles/getting-started-with-rails3 * Developer: ​Nguyễn Thành Luân