• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Хокку про Heroku
 

Хокку про Heroku

on

  • 343 views

 

Statistics

Views

Total Views
343
Views on SlideShare
343
Embed Views
0

Actions

Likes
0
Downloads
4
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Хокку про Heroku Хокку про Heroku Presentation Transcript

    • Хокку про Heroku Сергей Селецкий @sseletskyy Европейское Агентство Высоких Технологий http://www.foss-sea.org.ua/ 2013
    • Что такое Paas (Product as a Service) Cloud сервер + Agile + масштабирование
    • Что такое Paas (Product as a Service) с финансовой точки зрения ● нет затрат на покупку серверов ● на покупку серверного ПО ● на зарплату администратора ● ежемесячная оплата услуг PaaS
    • GIT SOURCE CODE HEROKU $ git push heroku your_branch:master
    • $ heroku ps:scale web=1 worker=1 LOAD BALANCER HEROKU STATELESS INSTANCE WEB DYNO PostgreSQL STATELESS INSTANCE WORKER DYNO
    • $ heroku ps:scale web=2 worker=2 LOAD BALANCER HEROKU STATELESS STATELESS INSTANCE INSTANCE WEB DYNO DYNO PostgreSQL STATELESS STATELESS INSTANCE INSTANCE WORKER DYNO DYNO
    • $ heroku ps:scale web=3 worker=3 LOAD BALANCER HEROKU STATELESS STATELESS INSTANCE STATELESS INSTANCE INSTANCE DYNO WEB DYNO DYNO PostgreSQL STATELESS STATELESS INSTANCE STATELESS INSTANCE INSTANCE DYNO WORKER DYNO DYNO
    • $ heroku ps:scale web=5 worker=5 LOAD BALANCER HEROKU STATELESS STATELESS INSTANCE STATELESS INSTANCE STATELESS INSTANCE STATELESS INSTANCE DYNO INSTANCE DYNO DYNO WEB DYNO DYNO PostgreSQL STATELESS STATELESS INSTANCE STATELESS INSTANCE STATELESS INSTANCE STATELESS INSTANCE DYNO INSTANCE DYNO DYNO WORKER DYNO DYNO
    • ==> heroku login Enter your Heroku credentials. Email: gustotune@gmail.com Password (typing will be hidden): Found the following SSH public keys: 1) id_rsa.pub 2) id_rsa_cloud.pub Which would you like to use with your Heroku account? 2 Uploading SSH public key /Users/gustotune/. ssh/id_rsa_cloud.pub... failed ! This key is already in use by another account. Each account must have a unique key.
    • /Users/gustotune ==> ssh-keygen -t rsa -C "gustotune@gmail.com" Generating public/private rsa key pair. Enter file in which to save the key (/Users/gustotune/. ssh/id_rsa): id_rsa_gustotune Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in id_rsa_gustotune. Your public key has been saved in id_rsa_gustotune. pub. /Users/gustotune ==> mv id_rsa_gustotune* .ssh/
    • /Users/gustotune ==> heroku login Enter your Heroku credentials. Email: gustotune@gmail.com Password (typing will be hidden): password is here Found the following SSH public keys: 1) id_rsa.pub 2) id_rsa_cloud.pub 3) id_rsa_gustotune.pub Which would you like to use with your Heroku account? 3 Uploading SSH public key /Users/gustotune/. ssh/id_rsa_gustotune.pub... done Authentication successful.
    • /Users/gustotune/rails_app ==> git config -e # комментарий: добавить три строчки в конец файла [remote "foss-sea"] url = git@heroku.com:foss-sea.git fetch = +refs/heads/*:refs/remotes/heroku/* или тоже самое одной командой ==> heroku git:remote -a foss-sea -r foss-sea где -a - это название приложения -r - это git remote name (‘heroku’ по умолчанию)
    • /Users/gustotune/rails_app ==> git push foss-sea heroku:master foss-sea = remote git repo in git config heroku = our local branch (локальная ветка) master = default branch at foss-sea еще примеры ==> git push foss-sea master:master ==> git push foss-sea release_1.0:master
    • ==> git push foss-sea heroku:master Counting objects: 8212, done. Delta compression using up to 4 threads. Compressing objects: 100% (2822/2822), done. Writing objects: 100% (8212/8212), 9.68 MiB | 74.00 KiB/s, done. Total 8212 (delta 5114), reused 8101 (delta 5027) -----> Ruby app detected -----> Compiling Ruby/Rails -----> Using Ruby version: ruby-2.0.0 -----> Installing dependencies using Bundler version 1.3.2 New app detected loading default bundler cache Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin --deployment Fetching source index from https://rubygems.org/ Asset precompilation completed (28.32s) Cleaning assets -----> Discovering process types Procfile declares types -> web Default types for Ruby -> console, rake, worker -----> Compiled slug size: 55.3MB -----> Launching... done, v5 http://foss-sea.herokuapp.com deployed to Heroku To git@heroku.com:foss-sea.git * [new branch] heroku -> master
    • Подготовка базы данных /Users/gustotune/rails_app ==> heroku run rake db:version Running `rake db:version` attached to terminal... up, run.9905 Current version: 0 /Users/gustotune/rails_app ==> heroku run rake db:migrate Running `rake db:migrate` attached to terminal... up, run.7096 Migrating to DeviseCreateUsers (20130910211249) == DeviseCreateUsers: migrating ============================================== -- create_table(:users) -> 0.0398s -- add_index(:users, :email, {:unique=>true}) -> 0.0203s -- add_index(:users, :reset_password_token, {:unique=>true}) -> 0.0260s -- add_index(:users, :confirmation_token, {:unique=>true}) -> 0.0222s == DeviseCreateUsers: migrated (0.1091s) ...
    • БИНГО ;)
    • Работа с дополнениями add-ons
    • /Users/gustotune/rails_app ==> heroku addons:add logentries Adding logentries on foss-sea... failed ! Please verify your account to install this add-on ! For more information, see http://devcenter.heroku.com/categories/billing ! Verify now at https://heroku.com/verify ==> heroku addons:add newrelic:stark Adding newrelic:stark on foss-sea... done, v7 (free) Use `heroku addons:docs newrelic` to view documentation. ==> heroku addons:add pgbackups:auto-month Adding pgbackups:auto-month on foss-sea... done, v8 (free) You can now use "pgbackups" to backup your databases or import an external backup. Use `heroku addons:docs pgbackups` to view documentation. ==> heroku addons:add rollbar Adding rollbar on foss-sea... done, v9 (free) Use `heroku addons:docs rollbar` to view documentation. ==> heroku addons:add sendgrid Adding sendgrid on foss-sea... done, v10 (free) Use `heroku addons:docs sendgrid` to view documentation.
    • Настройка дополнений и переменных окружения
    • > heroku config:set MAILER_URL=foss-sea.herokuapp.com или так если используется собственный домен > heroku config:set MAILER_URL=foss-sea.custom-domain.io
    • Примеры дополнений
    • Играем с масштабированием и ценой
    • Полезные команды
    • ==> heroku ps # возвращает список работающих копий приложения === web (1X): `bundle exec passenger start -p $PORT --max-pool-size 2` web.1: up 2013/11/29 01:02:25 (~ 46m ago) ==> heroku ps:scale web=2 worker=1 Scaling web processes... done, now running 2 Scaling worker processes... done, now running 1 ==> heroku run bash # получить доступ к консоли сервера ==> heroku run rails c # получить доступ к консоли приложения ==> heroku run rake [your_rake_task] # вызвать rake задачу [your_rake_task] ==> heroku logs --tail #просмотреть логи ==> heroku labs:enable user-env-compile # решает ряд проблем при сборке ==> heroku fork -a foss-sea foss-sea-copy # делает полную копию приложения ==> heroku maintenance:on Enabling maintenance mode for foss-sea... done
    • Восстановление после неудачного обновления
    • Спасибо Сергей Селецкий @sseletskyy