1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-12-01 12:24:28 +01:00

[bug] version check is not working

This commit is contained in:
Sylvain 2020-07-01 16:56:21 +02:00
parent c24623dcff
commit 9ca64418e7
6 changed files with 27 additions and 17 deletions

View File

@ -2,6 +2,8 @@
- Fix a bug: health API is broken if ElasticSearch is not present
- Fix a bug: unable to sync members with stripe
- Fix a bug: version check is not working
- [TODO DEPLOY] `rails fablab:maintenance:clean_workers`
## v4.5.1 2020 July 1st

View File

@ -74,7 +74,7 @@ module Fablab
plugins&.each(&:notify_after_initialize)
require 'version'
Version.check_and_schedule
Version.check
end
end
end

View File

@ -37,6 +37,14 @@ close_period_reminder_worker:
free_disk_space:
cron: "0 5 * * 0" # every sunday at 5am
class: "FreeDiskSpaceWorker"
queue: default
queue: system
# schedule a version check, every week at the current day+time
# this will prevent that all the instances query the hub simultaneously
<% m = DateTime.current.minute - 1; h = DateTime.current.hour; d = DateTime.current.cwday %>
version_check:
cron: <%="#{m} #{h} * * #{d}" %>
class: 'VersionCheckWorker'
queue: system
<%= PluginRegistry.insert_code('yml.schedule') %>

View File

@ -7,4 +7,5 @@
- [default, 5]
- [devise_mailer, 3]
- [mailers, 3]
- [elasticsearch, 2]
- [elasticsearch, 2]
- [system, 1]

View File

@ -82,5 +82,14 @@ namespace :fablab do
require 'version'
puts Version.current
end
desc 'clean the cron workers'
task clean_workers: :environment do
Sidekiq::Cron::Job.destroy_all!
Sidekiq::Queue.new('system').clear
Sidekiq::Queue.new('default').clear
Sidekiq::DeadSet.new.clear
end
end
end

View File

@ -17,21 +17,11 @@ class Version
json['up_to_date']
end
# periodically retrieve the last published version from the hub and save it into the database
def self.check_and_schedule
job_name = 'Automatic version check'
# retrieve the last published version from the hub and save it into the database
def self.check
return if (Rails.env.development? || Rails.env.test?) && ENV['FORCE_VERSION_CHECK'] != 'true'
job = Sidekiq::Cron::Job.find name: job_name
unless job
# schedule a version check, every week at the current day+time
# this will prevent that all the instances query the hub simultaneously
m = DateTime.current.minute
h = DateTime.current.hour
d = DateTime.current.cwday
job = Sidekiq::Cron::Job.new(name: job_name, cron: "#{m} #{h} * * #{d}", class: 'VersionCheckWorker')
job.save
end
job.enque!
# check the version
VersionCheckWorker.perform_async
end
end