diff --git a/Gemfile b/Gemfile index f065aaa..1949d37 100644 --- a/Gemfile +++ b/Gemfile @@ -35,6 +35,7 @@ gem 'mongoid-grid_fs', github: 'ahoward/mongoid-grid_fs' gem 'kaminari' gem "impressionist" gem 'ckeditor' +gem 'unicorn' #built in modules eval(File.read(File.dirname(__FILE__) + '/built_in_extensions.rb')) diff --git a/config/mongoid.yml b/config/mongoid.yml index e16bcd4..d0cb610 100644 --- a/config/mongoid.yml +++ b/config/mongoid.yml @@ -1,62 +1,10 @@ development: - # Configure available database sessions. (required) sessions: - # Defines the default session. (required) default: - # Defines the name of the default database that Mongoid can connect to. - # (required). database: orbit_4_5 - # Provides the hosts the default session can connect to. Must be an array - # of host:port pairs. (required) hosts: - localhost:27017 - options: - # Change the default write concern. (default = { w: 1 }) - # write: - # w: 1 - - # Change the default consistency model to primary, secondary. - # 'secondary' will send reads to secondaries, 'primary' sends everything - # to master. (default: primary) - # read: secondary_preferred - - # How many times Moped should attempt to retry an operation after - # failure. (default: 30) - # max_retries: 30 - - # The time in seconds that Moped should wait before retrying an - # operation on failure. (default: 1) - # retry_interval: 1 - # Configure Mongoid specific options. (optional) - options: - - # Includes the root model name in json serialization. (default: false) - # include_root_in_json: false - - # Include the _type field in serializaion. (default: false) - # include_type_for_serialization: false - - # Preload all models in development, needed when models use - # inheritance. (default: false) - # preload_models: false - - # Protect id and type from mass assignment. (default: true) - # protect_sensitive_fields: true - - # Raise an error when performing a #find and the document is not found. - # (default: true) - # raise_not_found_error: true - - # Raise an error when defining a scope with the same name as an - # existing method. (default: false) - # scope_overwrite_exception: false - - # Use Active Support's time zone in conversions. (default: true) - # use_activesupport_time_zone: true - - # Ensure all times are UTC in the app side. (default: false) - # use_utc: false test: sessions: default: @@ -65,7 +13,14 @@ test: - localhost:27017 options: read: primary - # In the test environment we lower the retries and retry interval to - # low amounts for fast failures. max_retries: 1 retry_interval: 0 + +production: + sessions: + default: + # username: + # password: + database: orbit_4_5 + hosts: + - localhost:27017 diff --git a/config/unicorn.rb b/config/unicorn.rb new file mode 100644 index 0000000..6a221b7 --- /dev/null +++ b/config/unicorn.rb @@ -0,0 +1,26 @@ +# unicorn_rails -c config/unicorn.rb -E development -D +# kill -s USR2 PID_OF_MASTER + +rails_root = `pwd`.gsub("\n", "") + +rails_env = ENV['RAILS_ENV'] || 'production' +worker_processes (rails_env == 'production' ? 4 : 2) + +preload_app true + +timeout 30 + +listen "#{rails_root}/tmp/unicorn.sock", :backlog => 2048 +stderr_path "#{rails_root}/log/unicorn.log" +stdout_path "#{rails_root}/log/unicorn.log" + +before_fork do |server, worker| + + old_pid = "#{rails_root}/tmp/pids/unicorn.pid.oldbin" + if File.exists?(old_pid) && server.pid != old_pid + begin + Process.kill("QUIT", File.read(old_pid).to_i) + rescue Errno::ENOENT, Errno::ESRCH + end + end +end \ No newline at end of file