Skip to content

Instantly share code, notes, and snippets.

@jelder
Created April 8, 2015 20:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jelder/31b1fff30d4be43168ae to your computer and use it in GitHub Desktop.
Save jelder/31b1fff30d4be43168ae to your computer and use it in GitHub Desktop.
Dynamically configure Passenger based on current Dyno type
#!/bin/bash
# http://stackoverflow.com/questions/24634958/programmatically-detect-heroku-dyno-size-at-run-time/24634959#24634959
function dyno_size() {
case $(ulimit -u) in
256)
echo "1X"
;;
512)
echo "2X"
;;
32768)
echo "PX"
;;
*)
echo "unknown"
;;
esac
}
case $(dyno_size) in
1X)
echo "--min-instances=1 --max-pool-size=1"
;;
2X)
echo "--min-instances=3 --max-pool-size=3"
;;
PX)
echo "--min-instances=12 --max-pool-size=12"
;;
*)
echo "--min-instances=1 --max-pool-size=1"
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment