Created
April 4, 2013 09:15
-
-
Save abonhomme/5308972 to your computer and use it in GitHub Desktop.
Bash script for scaling a Heroku process via REST
(does NOT require the Heroku toolbelt to be installed)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
APP="YOUR_APP" | |
TOKEN="YOUR_TOKEN" | |
PROCESS="web" | |
QTY= | |
usage() | |
{ | |
cat << EOF | |
usage: $0 -n COUNT [OPTIONS] | |
This script can be used to scale a heroku process. The -n argument is required. | |
OPTIONS: | |
-h Show this message | |
-a Application name | |
-t API token that has access to the application | |
-p Process name | |
-n Desired number of processes | |
EOF | |
} | |
while getopts “hatpn:” OPTION | |
do | |
case $OPTION in | |
h) | |
usage | |
exit 1 | |
;; | |
a) | |
APP=$OPTARG | |
;; | |
t) | |
TOKEN=$OPTARG | |
;; | |
p) | |
PROCESS=$OPTARG | |
;; | |
n) | |
QTY=$OPTARG | |
;; | |
?) | |
usage | |
exit | |
;; | |
esac | |
done | |
if [[ -z $APP ]] || [[ -z $TOKEN ]] || [[ -z $PROCESS ]] || [[ -z $QTY ]] | |
then | |
usage | |
exit 1 | |
fi | |
curl -H "Accept: application/json" -u :$TOKEN -d "type=$PROCESS" -d "qty=$QTY" -X POST "https://api.heroku.com/apps/$APP/ps/scale" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment