diff --git a/app/config.ru b/app/config.ru index 56396f9..9450151 100644 --- a/app/config.ru +++ b/app/config.ru @@ -2,6 +2,5 @@ require './config/environment' require 'api' -require 'schedule' run Sinatra::Application diff --git a/app/config/unicorn.rb b/app/config/unicorn.rb index bb3101f..4010477 100644 --- a/app/config/unicorn.rb +++ b/app/config/unicorn.rb @@ -9,3 +9,8 @@ timeout 10 before_fork do |_, _| Sequel::DATABASES.each(&:disconnect) end + +fork do + require_relative 'environment' + require 'schedule' +end diff --git a/app/lib/schedule.rb b/app/lib/schedule.rb index 90064c7..6745176 100644 --- a/app/lib/schedule.rb +++ b/app/lib/schedule.rb @@ -8,3 +8,5 @@ schedule = Rufus::Scheduler.new schedule.cron '*/15 15,16,17 * * 1-5' do Bank.fetch_current_rates! end + +schedule.join