diff --git a/.gitignore b/.gitignore index b5780cc..e026528 100644 --- a/.gitignore +++ b/.gitignore @@ -23,6 +23,7 @@ Vagrantfile .vagrant config/database.yml config/unicorn.rb +config/puma.rb db/data.yml .idea *.iml diff --git a/Gemfile b/Gemfile index ea232cb..a414993 100644 --- a/Gemfile +++ b/Gemfile @@ -3,6 +3,7 @@ source 'https://gems.ruby-china.org' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '5.0.0' +gem 'puma' # Use mysql2 as the database for Active Record gem 'mysql2' # Use SCSS for stylesheets diff --git a/Gemfile.lock b/Gemfile.lock index 46dae72..d118b31 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -155,6 +155,7 @@ GEM coderay (~> 1.1.0) method_source (~> 0.8.1) slop (~> 3.4) + puma (3.6.0) rack (2.0.1) rack-test (0.6.3) rack (>= 1.0) @@ -273,6 +274,7 @@ DEPENDENCIES jquery-rails letter_opener mysql2 + puma rails (= 5.0.0) rspec-rails sass-rails diff --git a/config/puma.rb.example b/config/puma.rb.example new file mode 100644 index 0000000..0380584 --- /dev/null +++ b/config/puma.rb.example @@ -0,0 +1,19 @@ +app_root = '/Users/zoker/Hobby/Taskile' +pidfile "#{app_root}/tmp/pids/puma.pid" +state_path "#{app_root}/tmp/pids/puma.state" +stdout_redirect "#{app_root}/log/puma.stdout.log", "#{app_root}/log/puma.stderr.log", true +bind 'tcp://127.0.0.1:3001' +daemonize true +workers 2 +threads 4, 8 +preload_app! + +on_worker_boot do + ActiveSupport.on_load(:active_record) do + ActiveRecord::Base.establish_connection + end +end + +before_fork do + ActiveRecord::Base.connection_pool.disconnect! +end