SlideShare ist ein Scribd-Unternehmen logo
1 von 24
Capistrano実践Tips集 2009/09/07 高倉 利明
目次 これだけは入れとけ!便利なgem こう記述しろ!設定ファイル 意外と知らない?注意点
1.これだけは入れとけ!  便利なgem ・capistrano_colors ・capistrano-ext ※インストール方法は割愛。  ググれ!
capistrano_colors 何ができる? ->capistranoの実行コマンド、  コメントなどを色づけしてくれる。  地味だけど便利。 使用後 使用前
capistrano-ext 何ができる? ->環境に応じたcapistrano  設定を差分ファイルで  上書きする事が可能になる。
capistrano-ext フォルダ構成 Root └ /config    └ deploy.rb (共通設定)    └/deploy    └staging.rb(staging差分)    └production.rb(production差分)
capistrano-ext 環境ごとの「user」を置き換えたいなら。。。 #config/deploy.rb set:user,     “hogehoge“ #config/deploy/staging.rb set:user,     “fugafuga“ #config/deploy/production.rb set:user,     “piyopiyo“
capistrano-ext ステージング環境へデプロイ 本番環境へデプロイ $ cap staging deploy $ cap production deploy
2.こう記述しろ!設定ファイル (1) deploy.rbデフォルト記述 (2) Passengerとの連携設定 (3) パスワードなどの動的入力 (4) プッシュ式デプロイ
(1) deploy.rbデフォルト記述 Q.deploy.rbファイル書くの面倒だよ!   何かいい手ない? A.APサーバで以下のデフォルトルールに従えば~ Railsの実行ユーザは「app」 アプリ設置場所は「/u/apps」 「app」ユーザに「/u/apps」以下のファイル作成・削除権限を与える サーバに公開鍵などでの  パスワード無しsshログイン可能
(1) deploy.rbデフォルト記述 7行で済みます。 #config/deploy.rb set :application,      “test “ set :scm,                  “subversion“ set :scm_user,         “hogehoge“ set :scm_password, “fugafuga“ role :web, “web.test.com“ role :app,  “app.test.com“ role :db,    “db.test.com “
(2) Passengerとの連携設定 Q.CapistranoをPassengerと  連携させたいんだけど、  何か記述しておいた方が良い? A.Passengerは「tmp/restart.txt 」  にファイルがあると、自動的に  そのアプリのみ再読み込みするので~
(2) Passengerとの連携設定 以下のように再起動タスクを記述しておくと便利。 #config/deploy.rb namespace :deploy do   task :restart, :roles => :app do     run "touch #{current_release}/tmp/restart.txt” end # 以下タスクはApache自体の起動/停止に使用。複数アプリを # 単一Apacheで公開している場合は使用しない方が良い  task :start, :roles => :appdo    run "sudo /etc/rc.d/init.dhttpd start " end  task :stop, :roles => :app do     run "sudo /etc/rc.d/init.dhttpd stop " end end
(3) パスワードなどの動的入力 Q.capistranoでセキュリティ要件が厳しいとき、  以下のような要望が出てくる。  さあどうしよう? セキュリティ要件でパスワードを設定ファイル上にベタ書きするのはNG Subversionサーバのパスワードをデプロイ担当者ごとに使い分けたい APサーバのパスワードをデプロイ担当者ごとに使い分けたい ...etc
(3) パスワードなどの動的入力 A.Capistrano::CLIを使用すれば  動的入力できる! #config/deploy.rb # 入力(エコーバックあり) set :scm_userdo   Capistrano::CLI.ui.ask (“scm user:”) end # パスワード (エコーバックなし) set :scm_passworddo   Capistrano::CLI.password_prompt(“scm pass:”) end
(4)プッシュ式デプロイ Q.セキュリティ上APサーバからSubversionリポジトリに  アクセス出来ないんだって!  これではデプロイできない。。。助けて! APサーバ Subversionサーバ Capistrano実行サーバ
(4)プッシュ式デプロイ A. 「deploy_via, :copy」オプションを  使うことで、プッシュ式デプロイを行いましょう。 #config/deploy.rb set :deploy_via, :copy
(4)プッシュ式デプロイ deploy_via:copyを設定すると  1. capistrano実行サーバにチェックアウト  2. APサーバにgzip圧縮してscpアップロード  3. APサーバ上で展開して配置 という流れでデプロイを行う事ができます。 APサーバ ③ ② ① Capistrano実行サーバ Subversionサーバ
3.意外と知らない?注意点 ・role:dbの意味 ・ユーザのアップロード画像などは  どこに置くべき?
role:dbの意味 Q. role :dbに指定するサーバは、 DBサーバで良いんだよね? A. いいえ。  ×:DBサーバ  ○:Migrationを実行するサーバ  (ほとんどの場合APサーバと同じで良い)
ユーザのアップロード画像置き場所 Q.ユーザがアップロードした画像とか  docファイルとかって、  どこに配置しておくのが良いのかな?
ユーザのアップロード画像置き場所 A.shared/system以下にに置き、capistranoで  public以下へシンボリックリンクを  張りましょう。 myapp  └ current  └ releases---20091122010101(最新アプリ)  └ shared                 └log    └ log                   └public    └ system                  └ user_img         └ user_img シンボリックリンク シンボリックリンク シンボリックリンク
ユーザのアップロード画像置き場所 シンボリックリンクを張る例: #config/deploy.rb after “deploy”, “deploy:link_images” namespace(:deploy) do  task :link_imagesdo    run <<-CMD cd #{release_path} && ln –nfs #{shared_path}/user_images        #{release_path}/public/user_images     CMD end end
ご静聴 ありがとう ございました。

Weitere ähnliche Inhalte

Andere mochten auch

Ogt 2006
Ogt 2006Ogt 2006
Ogt 2006
ham97
 
The cold war heats up
The cold war heats upThe cold war heats up
The cold war heats up
ham97
 
People in societies and history
People in societies and historyPeople in societies and history
People in societies and history
ham97
 

Andere mochten auch (20)

Redmineチケットによるプロジェクト火消し戦略!
Redmineチケットによるプロジェクト火消し戦略!Redmineチケットによるプロジェクト火消し戦略!
Redmineチケットによるプロジェクト火消し戦略!
 
ChefとCapistranoの境界線 (Chef Casual Talks Vol.1) #eytokyo #opschef_ja
ChefとCapistranoの境界線 (Chef Casual Talks Vol.1) #eytokyo #opschef_jaChefとCapistranoの境界線 (Chef Casual Talks Vol.1) #eytokyo #opschef_ja
ChefとCapistranoの境界線 (Chef Casual Talks Vol.1) #eytokyo #opschef_ja
 
Goとテスト
GoとテストGoとテスト
Goとテスト
 
Vagrant + Puppet
Vagrant + PuppetVagrant + Puppet
Vagrant + Puppet
 
Go入門
Go入門Go入門
Go入門
 
意識の低い自動化
意識の低い自動化意識の低い自動化
意識の低い自動化
 
[社内勉強会]ELBとALBと数万スパイク負荷テスト
[社内勉強会]ELBとALBと数万スパイク負荷テスト[社内勉強会]ELBとALBと数万スパイク負荷テスト
[社内勉強会]ELBとALBと数万スパイク負荷テスト
 
The Wisdom Of The Cross
The  Wisdom Of The  CrossThe  Wisdom Of The  Cross
The Wisdom Of The Cross
 
Ogt 2006
Ogt 2006Ogt 2006
Ogt 2006
 
Diete e Social Network: analisi delle conversazioni on line
Diete e Social Network: analisi delle conversazioni on lineDiete e Social Network: analisi delle conversazioni on line
Diete e Social Network: analisi delle conversazioni on line
 
La cruz del cambio
La cruz del cambioLa cruz del cambio
La cruz del cambio
 
Digital Design Trends
Digital Design TrendsDigital Design Trends
Digital Design Trends
 
Russia Chapter for Getting the Deal Through Real Estate 2010 edition
Russia Chapter for Getting the Deal Through Real Estate 2010 editionRussia Chapter for Getting the Deal Through Real Estate 2010 edition
Russia Chapter for Getting the Deal Through Real Estate 2010 edition
 
The cold war heats up
The cold war heats upThe cold war heats up
The cold war heats up
 
2. De trabajador a colaborador
2. De trabajador a colaborador2. De trabajador a colaborador
2. De trabajador a colaborador
 
Costruire la reputazione tra università e impresa
Costruire la reputazione tra università e impresaCostruire la reputazione tra università e impresa
Costruire la reputazione tra università e impresa
 
Portfolio
PortfolioPortfolio
Portfolio
 
Giroidea - Our method
Giroidea - Our methodGiroidea - Our method
Giroidea - Our method
 
Elezioni sindaco 2016: la reputazione on line dei candidati di Milano e Roma ...
Elezioni sindaco 2016: la reputazione on line dei candidati di Milano e Roma ...Elezioni sindaco 2016: la reputazione on line dei candidati di Milano e Roma ...
Elezioni sindaco 2016: la reputazione on line dei candidati di Milano e Roma ...
 
People in societies and history
People in societies and historyPeople in societies and history
People in societies and history
 

Ähnlich wie Capistrano 実践Tips集

20090612 実践Redmine @ Redmine勉強会
20090612 実践Redmine @ Redmine勉強会20090612 実践Redmine @ Redmine勉強会
20090612 実践Redmine @ Redmine勉強会
Yusuke Ando
 
Sc2009autumn 次世代Daoフレームワーク Doma
Sc2009autumn 次世代Daoフレームワーク DomaSc2009autumn 次世代Daoフレームワーク Doma
Sc2009autumn 次世代Daoフレームワーク Doma
Toshihiro Nakamura
 
QM-076-六標準差管理方法的解題邏輯與策略
QM-076-六標準差管理方法的解題邏輯與策略QM-076-六標準差管理方法的解題邏輯與策略
QM-076-六標準差管理方法的解題邏輯與策略
handbook
 
Marriage 6 Line
Marriage 6 LineMarriage 6 Line
Marriage 6 Line
Long Yi
 
Open Source Type Pad Mobile
Open Source Type Pad MobileOpen Source Type Pad Mobile
Open Source Type Pad Mobile
Hiroshi Sakai
 
【13-C-4】 「もう業務はとまらない!オフライン機能を使った業務アプリケーションの実例と最新 Curl 情報」
【13-C-4】 「もう業務はとまらない!オフライン機能を使った業務アプリケーションの実例と最新 Curl 情報」【13-C-4】 「もう業務はとまらない!オフライン機能を使った業務アプリケーションの実例と最新 Curl 情報」
【13-C-4】 「もう業務はとまらない!オフライン機能を使った業務アプリケーションの実例と最新 Curl 情報」
devsumi2009
 

Ähnlich wie Capistrano 実践Tips集 (20)

Green IT
Green ITGreen IT
Green IT
 
sigfpai73-kaji
sigfpai73-kajisigfpai73-kaji
sigfpai73-kaji
 
20090612 実践Redmine @ Redmine勉強会
20090612 実践Redmine @ Redmine勉強会20090612 実践Redmine @ Redmine勉強会
20090612 実践Redmine @ Redmine勉強会
 
文献紹介:Semantic-based information retrieval in support of concept design.
文献紹介:Semantic-based information retrieval in support of concept design.文献紹介:Semantic-based information retrieval in support of concept design.
文献紹介:Semantic-based information retrieval in support of concept design.
 
Sc2009autumn 次世代Daoフレームワーク Doma
Sc2009autumn 次世代Daoフレームワーク DomaSc2009autumn 次世代Daoフレームワーク Doma
Sc2009autumn 次世代Daoフレームワーク Doma
 
Mhada
MhadaMhada
Mhada
 
QM-076-六標準差管理方法的解題邏輯與策略
QM-076-六標準差管理方法的解題邏輯與策略QM-076-六標準差管理方法的解題邏輯與策略
QM-076-六標準差管理方法的解題邏輯與策略
 
20090418 イケテルRails勉強会 第2部Air編 解説
20090418 イケテルRails勉強会 第2部Air編 解説20090418 イケテルRails勉強会 第2部Air編 解説
20090418 イケテルRails勉強会 第2部Air編 解説
 
僕らのかんばん方式 -Our Kanban Board-
僕らのかんばん方式 -Our Kanban Board-僕らのかんばん方式 -Our Kanban Board-
僕らのかんばん方式 -Our Kanban Board-
 
Assembly Definition あれやこれ
Assembly Definition あれやこれAssembly Definition あれやこれ
Assembly Definition あれやこれ
 
Marriage 6 Line
Marriage 6 LineMarriage 6 Line
Marriage 6 Line
 
Cloud Computing - クラウドコンピューティング(会津産学懇話会)
Cloud Computing - クラウドコンピューティング(会津産学懇話会)Cloud Computing - クラウドコンピューティング(会津産学懇話会)
Cloud Computing - クラウドコンピューティング(会津産学懇話会)
 
PHP超入門@LL温泉
PHP超入門@LL温泉PHP超入門@LL温泉
PHP超入門@LL温泉
 
Open Source Type Pad Mobile
Open Source Type Pad MobileOpen Source Type Pad Mobile
Open Source Type Pad Mobile
 
Search Engines Chapter 1 Summary
Search Engines Chapter 1 SummarySearch Engines Chapter 1 Summary
Search Engines Chapter 1 Summary
 
Cop",!@#%$%&*()*()
Cop",!@#%$%&*()*()Cop",!@#%$%&*()*()
Cop",!@#%$%&*()*()
 
20090522 Candycane
20090522 Candycane20090522 Candycane
20090522 Candycane
 
スケールするiPhone/Smart Phoneビジネス
スケールするiPhone/Smart PhoneビジネススケールするiPhone/Smart Phoneビジネス
スケールするiPhone/Smart Phoneビジネス
 
【13-C-4】 「もう業務はとまらない!オフライン機能を使った業務アプリケーションの実例と最新 Curl 情報」
【13-C-4】 「もう業務はとまらない!オフライン機能を使った業務アプリケーションの実例と最新 Curl 情報」【13-C-4】 「もう業務はとまらない!オフライン機能を使った業務アプリケーションの実例と最新 Curl 情報」
【13-C-4】 「もう業務はとまらない!オフライン機能を使った業務アプリケーションの実例と最新 Curl 情報」
 
Ph4
Ph4Ph4
Ph4
 

Kürzlich hochgeladen

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Kürzlich hochgeladen (20)

Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 

Capistrano 実践Tips集