Book Image

Heroku Cookbook

By : Mike Coutermarsh
Book Image

Heroku Cookbook

By: Mike Coutermarsh

Overview of this book

Heroku is a Platform as a Service that enables developers to rapidly deploy and scale their web applications. Heroku is designed for developer happiness, freeing developers from doing system administrative tasks such as configuring servers and setting up load balancers. Developers are able to focus on what they do best, building web applications, while leaving the details of deployment and scaling to the experts at Heroku. This practical guide is packed with step-by-step solutions to problems faced by every production-level web application hosted on Heroku. You'll quickly get comfortable with managing your Heroku applications from the command line and then learn everything you need to know to deploy and administer production-level web applications.
Table of Contents (17 chapters)
Heroku Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Scaling dynos and workers


Imagine if we could scale up our applications from our company chatroom? Or maybe even from our own custom admin panel? This is possible by integrating with the Heroku API. In this recipe, we'll be introduced to managing processes with the Platform API gem. This will give us the start we need to write our own code to handle scaling our Heroku applications.

Note

Be sure to complete the previous recipe before attempting this one.

How to do it…

Let's get started by opening up a terminal and navigating to our heroku-api-examples directory. Then, we can perform the following steps:

  1. We can start by launching a console session to get familiar with the app commands:

    $ ruby console.rb
    
  2. Now that we have a console session running, let's get a list of our available applications from the API using app.list. This will return an array of hashes. Each item in the array is one of our applications.

    We should set the response to a variable so that we can work with it later on.

    $ apps = heroku_api...