Run scheduler in a separate process

This commit is contained in:
Hakan Ensari 2017-12-31 17:13:51 +00:00
parent 0874b54375
commit a0a16684a6
3 changed files with 7 additions and 1 deletions

View File

@ -2,6 +2,5 @@
require './config/environment' require './config/environment'
require 'api' require 'api'
require 'schedule'
run Sinatra::Application run Sinatra::Application

View File

@ -9,3 +9,8 @@ timeout 10
before_fork do |_, _| before_fork do |_, _|
Sequel::DATABASES.each(&:disconnect) Sequel::DATABASES.each(&:disconnect)
end end
fork do
require_relative 'environment'
require 'schedule'
end

View File

@ -8,3 +8,5 @@ schedule = Rufus::Scheduler.new
schedule.cron '*/15 15,16,17 * * 1-5' do schedule.cron '*/15 15,16,17 * * 1-5' do
Bank.fetch_current_rates! Bank.fetch_current_rates!
end end
schedule.join