Sie sind auf Seite 1von 3

7.

Advance >
7.3. Deploy to Staging
7.3.1. Cloud
In computer terms Cloud is server that can controll remoted by user for install application, using application, store data via internet. Cloud devide into three
category :
1. Infrastructure as a Service (IaaS), this Cloud allow user for congure operating system, virtual machine, network rule in server.
2. Platform as a Service (PaaS), this Cloud allow user for congure web server, database.
3. Software as a Service (SaaS), this Cloud allow user for install applications and using that application.
For complete resources : http://en.wikipedia.org/wiki/Cloud_computing#Service_models
And for Ruby on Rails using PaaS, in the market there many choice (http://en.wikipedia.org/wiki/Platform_as_a_service#Examples) and here we will using service
from Heroku.
7.3.2. PaaS with Heroku
Workow
https://devcenter.heroku.com/articles/development-conguration
Best Practice
1. Lets create new account in Heroku, go to : https://signup.heroku.com/dc , after you sign-up you need conrm your email for insert new password your account.
2. after success conrm and insert new password you need install Heroku Toolbelt (package for access Heroku command line), on terminal run :
wget -q0- https://toolbelt.heroku.com/install-ubuntu.sh | sh
for check if toolbelt success installed run :
heroku help
Login to heroku server from console, on terminal run :
heroku login
that will asking for email and password account heroku, after authentication success heroku will check the ssh key in your local, if found heroku will asking if
you want using that key, type Yes for using existing one, but if not heroku will asking you if you want generate the ssh key.
For details about ssh key you can check with :
heroku keys help
3. Setup heroku remote to Ruby on Rails project, on terminal run :
cd <name_rails_app>
after move to your project directory now create new Staging in Heroku for our project, run :
heroku create <name-heroku-staging> --remote staging
if success it will give url path to your staging, like : http://name-heroku-staging.herokuapp.com , and when access from browser it only show welcome page. And if your
check git conguration with :
git config --list
will add remote to staging in git conguration :
remote.origin.url=git@github.com:dwikuntobayu/learn_git_local.git
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
remote.staging.url=git@heroku.com:learn-rails4-staging.git
remote.staging.fetch=+refs/heads/*:refs/remotes/staging/*
that means you have two remote repository rst to github and the second to staging heroku, whenever you push to staging that not automatic push to github.
After success create Staging now we need setup Heroku Cong Vars (this conguration allow us for working in Staging environmet, on terminal run :
heroku config:set RAILS_ENV=staging --app name-heroku-staging
https://sites.google.com/a/kiranatama.com/modul...
1 of 3 10/13/2014 07:43 PM
check the heroku conguration, run :
heroku config
that will result :
=== name-heroku-staging Cong Vars
DATABASE_URL: postgres://btulrythdaubjg:Ux4TDPYH06LrVpAY7uPZY6_@ec2-54-204-27-119.compute-1.amazonaws.com:5432/d2t1tepp6vncot
HEROKU_POSTGRESQL_COBALT_URL: postgres://btulrythdaubjg:Ux4Y54TDPAY7uPZY6_@ec2-54-204-27-119.compute-1.amazonaws.com:5432/d2t1tepp6vncot
LANG: en_US.UTF-8
RACK_ENV: production
RAILS_ENV: staging
SECRET_KEY_BASE: eed723c677be5c7ecc87e1ade1b3b426d96b594e115de00477b79cf9a2c7860ab69f3ca59749f7d3681a177fbf67e2edd3025b2d88888cc8
4. Congure Application before push to Staging, congure :
4.1. Gemle with :
- add ruby version
- add gem rails_12factor, this gem use for setup custom environment
- in Staging we will using Thin webserver
now open your_rails_application/Gemle , add :
ruby "1.9.3"
gem 'rails_12factor', group: "production"
gem 'thin'
after add that don't forget for run bundle :
bundle install
4.2. Procle
Procle is le use for tell to Heroku if we will using Thin server rather than Webric server, the le will put in your_rails_application/, on terminal run :
echo 'web: bundle exec thin start -p $PORT' > Procle
4.3. Secret Key Base
Secret key base for staging can add in your_rails_application/cong/secrets.yml, and add :
staging:
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
save all changes and don't forget for add then commit all changes to git.
5. Push RoR4 application to Staging, make sure you has inside the application on terminal run :
git push staging master
make sure push process not have error or warnings.
After push to staging now we need check if service (dyno) is run :
heroku ps:scale web=1
that will result :
Scaling dynos... done, now running web at 1:1X.
for complete resource about dyno http://stackoverow.com/questions/4536326/heroku-free-account-limited
then check if thin server is working :
heroku ps --remote staging
that will result :
=== web (1X): `bundle exec thin start -p $PORT`
web.1: up 2014/10/10 23:55:16 (~ 36m ago)
that means thin server is already running.
6. Setup migration in staging, on terminal run :
heroku run rake db:migrate
https://sites.google.com/a/kiranatama.com/modul...
2 of 3 10/13/2014 07:43 PM
after migrate the table now we will restart the staging :
heroku restart -a name-heroku-staging
7. Check if application success running, in browser run : http://name-heroku-staging.herokuapp.com
Trobleshooting :
1. Email conrmation not working :
- move smtp conguration from cong/environtments/development.rb :
cong.action_mailer.raise_delivery_errors = true
cong.action_mailer.delivery_method = :smtp
cong.action_mailer.smtp_settings = {
:address => "smtp.gmail.com",
:port => 465,
:domain => "gmail.com",
:user_name => "develror",
:password => "12345^&*()",
:authentication => "login",
:ssl => true,
:tls => true,
:enable_starttls_auto => true
}
into app/mailers/conrmation_mailer.rb , puts before class ConrmationMailer :
require "action_mailer"
ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
:address => "smtp.gmail.com",
:port => 465,
:domain => '@gmail.com',
:user_name => 'develror',
:password => '12345^&*()',
:authentication => "plain",
:ssl => true,
:tls => true,
:enable_starttls_auto => true
}
2. Mail Conrmation Errors Net::SMTPAuthenticationError: 534-5.7.14
- if mail conrmation errors Net::SMTPAuthenticationError: 534-5.7.14, that means google block smtp for attempt for login to account. Google engine will check
the current login location and compare with smtp location, if it is considered supicious google will prevent smtp for login. So you need conrm if smtp will login
is you, goto :
https://accounts.google.com/DisplayUnlockCaptcha
then click continue, after that goto :
https://security.google.com/settings/security/activity?pli=1
and conrm allow login.
https://sites.google.com/a/kiranatama.com/modul...
3 of 3 10/13/2014 07:43 PM

Das könnte Ihnen auch gefallen