diff --git a/.buildpacks b/.buildpacks index eb20a5d0..36201cad 100644 --- a/.buildpacks +++ b/.buildpacks @@ -1,2 +1,3 @@ https://github.com/heroku/heroku-buildpack-ruby.git https://github.com/drogus/last-commit-sha-buildpack.git +https://github.com/ryandotsmith/nginx-buildpack.git diff --git a/Procfile b/Procfile index bbb53736..42675c0c 100644 --- a/Procfile +++ b/Procfile @@ -1,2 +1,2 @@ -web: bundle exec ./script/server +web: bin/start-nginx bundle exec ./script/server console: bundle exec ./script/console diff --git a/config/puma-config.rb b/config/puma-config.rb new file mode 100644 index 00000000..38d7628e --- /dev/null +++ b/config/puma-config.rb @@ -0,0 +1,9 @@ +root = File.expand_path('../..', __FILE__) + +rackup "#{root}/config.ru" + +bind 'unix:///tmp/nginx.socket' + +environment ENV['RACK_ENV'] || 'development' + +threads 0, 16 diff --git a/lib/travis/api/app.rb b/lib/travis/api/app.rb index 2fc29a40..8b6a8ab6 100644 --- a/lib/travis/api/app.rb +++ b/lib/travis/api/app.rb @@ -12,6 +12,7 @@ require 'raven' require 'sidekiq' require 'metriks/reporter/logger' require 'travis/support/log_subscriber/active_record_metrics' +require 'fileutils' # Rack class implementing the HTTP API. # Instances respond to #call. @@ -45,6 +46,7 @@ module Travis::Api def self.setup(options = {}) setup! unless setup? Endpoint.set(options) if options + FileUtils.touch('/tmp/app-initialized') end def self.new(options = {}) diff --git a/script/server b/script/server index a17c4245..05517d05 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 config.ru -p $PORT -e $RACK_ENV --threads 0:16" +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" exec $cmd