-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Leyla Kapi
committed
Mar 21, 2014
1 parent
a8fcb45
commit 83b2cbd
Showing
6 changed files
with
90 additions
and
2 deletions.
There are no files selected for viewing
77 changes: 77 additions & 0 deletions
77
source/posts/2013-09-10-capistrano-ile-multistage-deploy.html.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
--- | ||
title: Capistrano ile Multistage Deploy | ||
date: 2013-09-10 23:48 UTC | ||
tags: capistrano, deploy, ruby on rails | ||
--- | ||
|
||
Ürünlerimizi geliştirme aşamasında production ve staging olarak iki sunucuya deploy ediyoruz. Hafta bitiminde yaptığımız işleri staging sunucusuna deploy edip test edilmesini bekliyoruz. Onay geldiğinde ise production sunucusuna gönderiyoruz. | ||
|
||
Deploy işlermlerinde bildiğiniz gibi capistrano kullanıyoruz. İşlemleri halihazırda capistrano kullandığınızı düşünerek anlatacağım. | ||
|
||
`config/deploy.rb` ye capistrano multistage extension ekliyoruz. | ||
|
||
# config/deploy.rb | ||
require 'capistrano/ext/multistage' | ||
|
||
|
||
ve hangi stage ler olacağını belirtiyoruz | ||
|
||
# config/deploy.rb | ||
set :stages, %w(staging production) | ||
|
||
|
||
config altına deploy adında bir klasör oluşturup içerisine `production.rb` ve `staging.rb` dosyalarını oluşturuyoruz. | ||
|
||
# config/deploy/staging.rb | ||
server "156.0.0.0", :web, :app, :db, primary: true | ||
set :port, 1234 | ||
set :rails_env, 'staging' | ||
|
||
namespace :deploy do | ||
task :setup_config, roles: :app do | ||
# Staging | ||
sudo "ln -nfs #{current_path}/config/nginx.conf /etc/nginx/sites-enabled/#{application}" | ||
|
||
sudo "ln -nfs #{current_path}/config/unicorn_init_#{rails_env}.sh /etc/init.d/unicorn_#{application}" | ||
end | ||
end | ||
|
||
# config/deploy/production.rb | ||
server "156.0.0.0", :web, :app, :db, primary: true | ||
set :port, 1234 | ||
set :rails_env, 'production' | ||
|
||
namespace :deploy do | ||
task :setup_config, roles: :app do | ||
# Production | ||
sudo "ln -nfs #{current_path}/config/nginx-ssl.conf /etc/nginx/sites-enabled/#{application}" | ||
|
||
sudo "ln -nfs #{current_path}/config/unicorn_init_#{rails_env}.sh /etc/init.d/unicorn_#{application}" | ||
end | ||
end | ||
|
||
|
||
Kodlardan da anlaşılacağı gibi birbirinden farklı olacak şeyleri ayrı dosyalara taşıdık. Ortak olanlar ise `deploy.rb` de kalıyor. | ||
|
||
Deploy kodunuda şu şekilde çalıştırıyoruz. | ||
|
||
cap production deploy | ||
cap staging deploy | ||
|
||
|
||
veya | ||
|
||
# config/deploy.rb | ||
set :default_stage, "staging" | ||
|
||
|
||
default stage belirtip | ||
|
||
cap deploy | ||
|
||
|
||
yapıyoruz. | ||
|
||
Kolaylıklar dilerim. | ||
|
||
[Muhammet DİLEK](http://twitter.com/muhammetdilek) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -127,3 +127,5 @@ Css çıktısı: | |
float: right; | ||
width: 31.25%; | ||
} | ||
|
||
[Safiye Sepetçi](http://twitter.com/safiyesepetci) |