diff --git a/Gemfile b/Gemfile index 4ebc17f3..77295f28 100644 --- a/Gemfile +++ b/Gemfile @@ -9,7 +9,7 @@ gem 'travis-sidekiqs', github: 'travis-ci/travis-sidekiqs', require: nil, ref: ' gem 'sinatra' gem 'sinatra-contrib', require: nil #github: 'sinatra/sinatra-contrib', require: nil -gem 'puma', '2.3.1' +gem 'unicorn' gem 'sentry-raven', github: 'getsentry/raven-ruby' gem 'yard-sinatra', github: 'rkh/yard-sinatra' gem 'rack-contrib', github: 'rack/rack-contrib' diff --git a/Gemfile.lock b/Gemfile.lock index 53a779da..fe2abf3f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -159,6 +159,7 @@ GEM i18n (0.6.5) journey (1.0.4) json (1.8.0) + kgio (2.8.0) listen (1.2.2) rb-fsevent (>= 0.9.3) rb-inotify (>= 0.9) @@ -186,8 +187,6 @@ GEM coderay (~> 1.0.5) method_source (~> 0.8) slop (~> 3.4) - puma (2.3.1) - rack (>= 1.1, < 2.0) pusher (0.11.3) multi_json (~> 1.0) signature (~> 0.1.6) @@ -209,6 +208,7 @@ GEM rake (>= 0.8.7) rdoc (~> 3.4) thor (>= 0.14.6, < 2.0) + raindrops (0.11.0) rake (0.9.6) rb-fsevent (0.9.3) rb-inotify (0.9.0) @@ -270,6 +270,10 @@ GEM polyglot polyglot (>= 0.3.1) tzinfo (0.3.37) + unicorn (4.6.3) + kgio (~> 2.6) + rack + raindrops (~> 0.7) uuidtools (2.1.4) yard (0.8.6.2) @@ -288,7 +292,6 @@ DEPENDENCIES micro_migrations! mocha (~> 0.12) pry - puma (= 2.3.1) rack-attack rack-cache (~> 1.2) rack-contrib! @@ -303,4 +306,5 @@ DEPENDENCIES travis-core! travis-sidekiqs! travis-support! + unicorn yard-sinatra! diff --git a/config/unicorn.rb b/config/unicorn.rb index 45bae390..be3065d1 100644 --- a/config/unicorn.rb +++ b/config/unicorn.rb @@ -2,3 +2,10 @@ worker_processes 4 # amount of unicorn workers to spin up timeout 30 # restarts workers that hang for 15 seconds + +listen '/tmp/nginx.socket', backlog: 1024 + +require 'fileutils' +before_fork do |server,worker| + FileUtils.touch('/tmp/app-initialized') +end diff --git a/script/server b/script/server index 05517d05..3c88cd81 100755 --- a/script/server +++ b/script/server @@ -3,6 +3,6 @@ cd "$(dirname "$0")/.." [ $PORT ] || PORT=3000 [ $RACK_ENV ] || RACK_ENV=development -cmd="ruby -I lib -S bundle exec ruby -I lib -S puma -C config/puma-config.rb" -[[ $RACK_ENV == "development" ]] && exec rerun "$cmd -b tcp://127.0.0.1:$PORT" +cmd="ruby -I lib -S bundle exec ruby -I lib -S unicorn config.ru -E $RACK_ENV -c config/unicorn.rb" +[[ $RACK_ENV == "development" ]] && exec rerun "$cmd -l 127.0.0.1:$PORT" exec $cmd