Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Heroku at BattleHack Venice 2015

Heroku at BattleHack Venice 2015

Avatar for David Zuelke

David Zuelke

July 11, 2015
Tweet

More Decks by David Zuelke

Other Decks in Programming

Transcript

  1. FORKING APPS $  heroku  fork  -­‐-­‐from  sourceapp  -­‐-­‐to  targetapp  

    Creating  fork  targetapp...  done   Copying  slug...  done   Adding  heroku-­‐postgresql:dev...  done   Creating  database  backup  from  sourcapp...  ..  done   Restoring  database  backup  to  targetapp...  ..  done   Copying  config  vars...  done   Fork  complete,  view  it  at  http://targetapp.herokuapp.com/
  2. II. DEPENDENCIES Applications have explicitly declared dependencies. $  cat  composer.json

      {      "require":  {          "php":  ">=5.3.3",          "ext-­‐mcrypt":  "*",          "symfony/symfony":  "~2.4.6",          "twig/extensions":  "~1.0",          "symfony/monolog-­‐bundle":  "~2.4"      }   } $  cat  package.json   {      "dependencies":  {          "express":  "~4.9.x",          "cool-­‐ascii-­‐faces":  "~1.3.x"      },      "engines":  {          "node":  "0.10.x"      }   }
  3. III. CONFIGURATION Store config in the environment. Assumption: same code

    but different configuration per deployment target
  4. III. CONFIGURATION Store config in the environment. $smtp  =  parse_url(getenv('SMTP_GATEWAY_URL'));

      $transport  =  Swift_SmtpTransport::newInstance(
        $smtp['host'],  $smtp['port']
 )
        -­‐>setUsername($smtp['user'])
        -­‐>setPassword($smtp['pass'])
 ; Assumption: same code but different configuration per deployment target $  heroku  config:set  SMTP_GATEWAY_URL=\   smtp://joecool:[email protected]:827
  5. VI. PROCESSES heroku-­‐python-­‐app  $  cat  Procfile   worker:  python  worker.py

      web:  gunicorn  hello:app heroku-­‐node-­‐app  $  cat  Procfile   worker:  node  worker.js   web:  node  index.js heroku-­‐ruby-­‐app  $  cat  Procfile   worker:  env  TERM_CHILD=1  bundle  exec  rake  resque:work   web:  bundle  exec  unicorn  -­‐p  $PORT  -­‐c  ./config/unicorn.rb heroku-­‐php-­‐app  $  cat  Procfile   worker:  php  background.php   web:  vendor/bin/heroku-­‐php-­‐apache2  #  or  heroku-­‐php-­‐nginx
  6. SCALING $  heroku  ps:scale  web=5   Scaling  dynos...  done,  now

     running  web  at  5:1X.   $  heroku  ps   ===  web  (1X):  `bundle  exec  unicorn  -­‐p  $PORT`   web.1:  starting  2014/11/05  20:36:39  (~  4s  ago)   web.2:  starting  2014/11/05  20:36:39  (~  4s  ago)   web.3:  starting  2014/11/05  20:36:39  (~  4s  ago)   web.4:  starting  2014/11/05  20:36:38  (~  4s  ago)   web.5:  starting  2014/11/05  20:36:38  (~  4s  ago)   ===  worker  (Free):  `bundle  exec  stalk  worker.rb`   worker.1:  up  for  1m   $  heroku  ps:scale  web=1   Scaling  dynos...  done,  now  running  web  at  1:1X.