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

T 客邦技術架構分享

Sheng-Je Lin
November 06, 2012

T 客邦技術架構分享

Sheng-Je Lin

November 06, 2012
Tweet

More Decks by Sheng-Je Lin

Other Decks in Programming

Transcript

  1. • 林聖哲 ◦ Vincent ◦ v1nc3ntlaw • T 客邦 ◦

    Ruby on Rails Developer ◦ Linux Server Administrator about.me/v1nc3ntlaw
  2. 不只 T 客邦 • Single Sign-On 單一登入 ◦ 科技 -

    T 客邦 ◦ 電玩 - 打電動 ◦ 攝影 - DIGIPHOTO ◦ 討論 - T17 ◦ 廣告系統、活動 Events All Powered by Rails
  3. 伺服器架構 Load Balancer (F5 BIG-IP) Web Front Server Farm Database

    • Debian Stable Release • Nginx + Passenger • Percona MySQL • DRBD + Heartbeat = High Availability S M Redis
  4. 分流的好處:分散伺服器壓力、HA T T、G G D D、17 D、17 17 T、G role

    app • delayed_job • cron job • sphinx • upload content role web SSO ADS Redis SSO ADS Redis Events Redmine Gitlab Nagios Cacti Staging 其它
  5. 團隊協作工具 • Redmine 專案管理系統 • SkyPE • IRC Channel ◦

    deploy 訊息 ◦ git push 訊息 ◦ redmine ticket 動態
  6. 專案開發流程 • Git • Github and Gitlab • A feature

    or bug a git branch • Deploy branch to staging for test • Pull Request • Master is always stable
  7. Single Sign-On • rubycas-server • devise ◦ rememberable ◦ trackable

    • devise_cas_authenticatable • omniauth-facebook
  8. ryanb/cancan EppO/rolify • cancan 權限控管 • rolify 賦予使用者角色和可管理項目 • 討論區的板主權限

    user.add_role(:moderator, Board.first) can :manage, Board do |board| user.has_role?(:moderator, board) end
  9. javan/whenever • writing and deploying cron jobs • require "whenever/capistrano"

    • 定時備份、跑 rake task 統計資料 every 1.hour, :at => 30 do rake "sitemap:refresh" end 30 * * * * /bin/bash -l -c 'cd /techbang/releases/20121101065201 && RAILS_ENV=production bundle exec rake sitemap:refresh'
  10. Private Gems • techbang-core 文章的草稿、審稿、發佈流程 • techbang-fronted 前端相關的 assets or

    helper • techbang-authentication 連接 SSO、Facebook 會員註冊、登入的功能
  11. 如果 techbang-authentication 裡最新的 git commit gemspect 版本號是 0.6.0 Gemfile 1.

    bundle install clone git repo 後無法切換到正確的 gemspec 版本 gem "techbang-authentication", "0.4.0", :github => "techbang-authentication" 2. 指定 git tag 或 git ref gem "techbang-authentication", :tag => "0.4.0", :github => "techbang-authentication" gem "techbang-authentication", :ref => "4aded", :github => "techbang-authentication" 3. 使用 private gem server 管理 gem 版本 source "https://private.gem.server" gem "techbang-authentication", "~> 0.4.0"
  12. Rails Composer 專案產生器 • An application template that creates a

    Rails starter app. Devise, OmniAuth, CanCan, Twitter Bootstrap...
  13. techbang-authentication • $ rails g techbang:authentication ◦ add migrations #

    change users table for our needed ◦ add techbang gems ◦ add sso & facebook settings • $ rake db:create && rake db:migrate • $ rails s 立刻可使用 T 客邦 SSO 登入的新專案
  14. AWS 雲端服務 • Route 53 for DNS Management • SES

    for sending mail • S3 for remote backup
  15. 資料收集 (雲端服務) • Google Webmaster Tools 檢查 SEO • Google

    Analytics 網站流量、訪客人數 • New Relic Rails app 效能