From 7cc2d25649987cdbad3e9f728e2c6fe622ce435d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Po=C3=A7a?= Date: Mon, 2 Apr 2018 12:14:27 +0100 Subject: [PATCH 1/2] use worker --- Procfile | 2 +- config/unicorn.rb | 6 ------ 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/Procfile b/Procfile index dfa2ae6e9..831908670 100644 --- a/Procfile +++ b/Procfile @@ -1,2 +1,2 @@ web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb -console: bundle exec racksh +worker: bundle exec rake work_jobs diff --git a/config/unicorn.rb b/config/unicorn.rb index 0171aba70..a20230995 100644 --- a/config/unicorn.rb +++ b/config/unicorn.rb @@ -2,16 +2,10 @@ timeout 30 preload_app true -@delayed_job_pid = nil - before_fork do |_server, _worker| # the following is highly recommended for Rails + "preload_app true" # as there's no need for the master process to hold a connection ActiveRecord::Base.connection.disconnect! if defined?(ActiveRecord::Base) - - @delayed_job_pid ||= spawn("bundle exec rake work_jobs") unless ENV["WORKER_EMBEDDED"] == "false" - - sleep 1 end after_fork do |_server, _worker| From 937d4c22497101444be5ffbd25791b110623b2f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Po=C3=A7a?= Date: Mon, 2 Apr 2018 15:51:09 +0100 Subject: [PATCH 2/2] wip --- Rakefile | 5 ----- app.json | 4 ---- 2 files changed, 9 deletions(-) diff --git a/Rakefile b/Rakefile index 65669e57e..cbedafe3b 100644 --- a/Rakefile +++ b/Rakefile @@ -23,11 +23,6 @@ end desc "Lazily fetch all feeds." task :lazy_fetch do - if ENV["APP_URL"] - uri = URI(ENV["APP_URL"]) - Net::HTTP.get_response(uri) - end - FeedRepository.list.each do |feed| Delayed::Job.enqueue FetchFeedJob.new(feed.id) end diff --git a/app.json b/app.json index 33f03cdaf..41c79c417 100644 --- a/app.json +++ b/app.json @@ -24,10 +24,6 @@ "description": "Force all clients to connect over SSL", "value": "true" }, - "WORKER_EMBEDDED": { - "description": "Force worker threads to be spawned by main process", - "value": "true" - }, "WORKER_RETRY": { "description": "Number of times to respawn the worker thread if it fails", "value": "3"