SlideShare una empresa de Scribd logo
1 de 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
ご静聴 ありがとう ございました。

Más contenido relacionado

Destacado

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
 

Destacado (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
 

Similar a 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
 

Similar a 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
 

Último

EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 

Último (20)

Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
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
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
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
 

Capistrano 実践Tips集