@@ -269,10 +269,8 @@ Veritabanı sunucunuz da hazırlandıktan sonra artık rails application'ununuz
269
269
Gemleri kurduktan sonra ` capify .` komutunu çalıştıralım. Oluşan ` config/deploy.rb` dosyasını aşağıdaki gibi düzenleyelim.
270
270
271
271
` ` ` ruby
272
- # -*- encoding : utf-8 -*-
273
272
require " bundler/capistrano"
274
- require " whenever/capistrano"
275
-
273
+ # require "whenever/capistrano"
276
274
277
275
set :stages, %w(staging production)
278
276
set :default_stage, " production"
@@ -340,7 +338,7 @@ namespace :deploy do
340
338
341
339
desc " Update the crontab file"
342
340
task :update_crontab, :roles => :db do
343
- run " cd #{release_path} && whenever --update-crontab #{application}"
341
+ # run "cd #{release_path} && whenever --update-crontab #{application}"
344
342
end
345
343
after " deploy:update_crontab" , " deploy:resque_setup"
346
344
@@ -368,11 +366,10 @@ set :rails_env, 'production'
368
366
namespace :deploy do
369
367
task :setup_config, roles: :app do
370
368
# Production
371
- sudo " ln -nfs #{current_path}/config/nginx.conf /etc/nginx/sites-enabled/#{application}"
372
-
369
+ sudo " ln -nfs #{current_path}/config/nginx.#{rails_env}.conf /etc/nginx/sites-enabled/#{application}"
373
370
sudo " ln -nfs #{current_path}/config/unicorn_init_#{rails_env}.sh /etc/init.d/unicorn_#{application}"
374
371
run " mkdir -p #{shared_path}/config"
375
- put File.read(" config/database.example.yml" ), " #{shared_path}/config/database.yml"
372
+ put File.read(" config/database.example.#{rails_env}. yml" ), " #{shared_path}/config/database.yml"
376
373
puts " Now edit the config files in #{shared_path}."
377
374
end
378
375
end
@@ -386,26 +383,36 @@ set :rails_env, 'staging'
386
383
namespace :deploy do
387
384
task :setup_config, roles: :app do
388
385
# Staging
389
- sudo " ln -nfs #{current_path}/config/nginx.conf /etc/nginx/sites-enabled/#{application}"
390
-
386
+ sudo " ln -nfs #{current_path}/config/nginx.#{rails_env}.conf /etc/nginx/sites-enabled/#{application}"
391
387
sudo " ln -nfs #{current_path}/config/unicorn_init_#{rails_env}.sh /etc/init.d/unicorn_#{application}"
392
388
run " mkdir -p #{shared_path}/config"
393
- put File.read(" config/database.example.yml" ), " #{shared_path}/config/database.yml"
389
+ put File.read(" config/database.example.#{rails_env}. yml" ), " #{shared_path}/config/database.yml"
394
390
puts " Now edit the config files in #{shared_path}."
395
391
end
396
392
end
397
393
` ` `
398
394
399
- Gemfile a ` gem ' unicorn' ` ekleyelim. ` config/unicorn_init_production` ve ` config/unicorn_init_staging` dosyalarını oluşturalım. Dosyaları şu şekilde güncelleyelim.
395
+ Gemfile a ` gem ' unicorn' ` ekleyelim. ` config/unicorn_init_production.sh` ve ` config/unicorn_init_staging.sh`
396
+ dosyalarını oluşturalım. Dosyaları şu şekilde güncelleyelim.
400
397
401
398
* https://gist.github.com/muhammetdilek/d45a30d5fd26889ef5ea
402
399
* https://gist.github.com/muhammetdilek/d37e6b31d1b02e652255
403
400
404
- ` project_name` kısmını proje ismiyle değiştiriniz.
401
+ Bu dosyalardan ` project_name` kısmını proje ismiyle değiştirmeyi unutmayınız.
402
+
403
+ Ardından yukarıdaki dosyaları çalıştırılabilir hale getirmek için, aşağıdakı komutu konsoldan çalıştırın.
404
+
405
+ ` ` ` bash
406
+ $ chmod +x config/unicorn_init_production.sh && chmod +x config/unicorn_init_staging.sh
407
+ ` ` `
408
+ Ardından;
405
409
406
- ` config/database.example.yml` dosyasını oluşturup sunucu için kullancağınız veritabnı bilgilerini yazınız.
410
+ ` config/database.example.staging.yml` ve ` config/database.example.production.yml` dosyalarını oluşturup
411
+ staging ve production sunucu için kullancağınız veritabanı bilgilerini ilgili environment değerleri ile oluşturunuz.
407
412
408
- ` config/nginx.conf` dosyasını oluşturup aşağıdaki gibi güncelleyiniz.
413
+ ` config/nginx.staging.conf` ve ` config/nginx.production.conf` dosyasını oluşturup aşağıdaki gibi güncelleyiniz.
414
+ Bu aşamada eğer staging ve production sunucularında farklı nginx ayarları yapmak isterseniz dosyaları modifiye edebilirsiniz.
415
+ Örneğin. Staging sunucu icin domain sadece ` ` ` stage.example.com` ` ` şeklinde kullanılabilir.
409
416
410
417
` ` ` shell
411
418
upstream project_name {
@@ -437,9 +444,9 @@ Gemfile a `gem 'unicorn'` ekleyelim. `config/unicorn_init_production` ve `config
437
444
}
438
445
` ` `
439
446
440
- ` project_name` olan yerleri değiştirmeyi unutmayınız.
447
+ ` project_name` olan yerleri proje ismi ile değiştirmeyi unutmayınız.
441
448
442
- Artık deploy için herşeyimiz hazır.
449
+ Artık deploy için hazırız.
443
450
444
451
Proje dizininde;
445
452
0 commit comments