@@ -392,13 +392,58 @@ namespace :deploy do
392392end
393393` ` `
394394
395- Gemfile a ` gem ' unicorn' ` ekleyelim. ` config/unicorn_init_production.sh` ve ` config/unicorn_init_staging.sh`
395+ Gemfile a ` gem ' unicorn' ` ekleyelim. Öncelikle ` config/unicorn.rb` dosyasını oluşturup Unicorn ayarlarını yapalım.
396+
397+ ` ` ` ruby
398+ @shared_dir = " /home/deployer/apps/project_name/shared/"
399+ @working_dir = " /home/deployer/apps/project_name/current/"
400+
401+ worker_processes 2
402+ working_directory @working_dir
403+ timeout 30
404+
405+ listen " /tmp/sockets/unicorn_project_name.sock" , :backlog => 64
406+
407+ pid_file = " #{@shared_dir}pids/unicorn.pid"
408+ old_pid = " #{pid_file}.oldbin"
409+
410+ pid pid_file
411+
412+ stderr_path " #{@shared_dir}log/unicorn.stderr.log"
413+ stdout_path " #{@shared_dir}log/unicorn.stdout.log"
414+
415+ preload_app true
416+
417+ # combine Ruby 2.0.0dev or REE with "preload_app true" for memory savings
418+ # http://rubyenterpriseedition.com/faq.html#adapt_apps_for_cow
419+ preload_app true
420+ GC.respond_to? (:copy_on_write_friendly=) and
421+ GC.copy_on_write_friendly = true
422+
423+ check_client_connection false
424+
425+ before_fork do | server, worker|
426+ # the following is highly recomended for Rails + "preload_app true"
427+ # as there's no need for the master process to hold a connection
428+ defined? (ActiveRecord::Base) and
429+ ActiveRecord::Base.connection.disconnect!
430+ end
431+
432+ after_fork do | server, worker|
433+ # the following is *required* for Rails + "preload_app true",
434+ defined? (ActiveRecord::Base) and
435+ ActiveRecord::Base.establish_connection
436+ end
437+
438+ ` ` `
439+
440+ Daha sonra ` config/unicorn_init_production.sh` ve ` config/unicorn_init_staging.sh`
396441dosyalarını oluşturalım. Dosyaları şu şekilde güncelleyelim.
397442
398443* https://gist.github.com/muhammetdilek/d45a30d5fd26889ef5ea
399444* https://gist.github.com/muhammetdilek/d37e6b31d1b02e652255
400445
401- Bu dosyalardan ` project_name` kısmını proje ismiyle değiştirmeyi unutmayınız.
446+ Bu dosyalarda ` project_name` kısmını proje ismiyle değiştirmeyi unutmayınız.
402447
403448Ardından yukarıdaki dosyaları çalıştırılabilir hale getirmek için, aşağıdakı komutu konsoldan çalıştırın.
404449
0 commit comments