Commit 0b29cb59 authored by Gabriel Mazetto's avatar Gabriel Mazetto

Migrate EE jobs from Sidetiq to Sidekiq-cron

parent 8534b4c6
class HistoricalDataWorker class HistoricalDataWorker
include Sidekiq::Worker include Sidekiq::Worker
include Sidetiq::Schedulable
recurrence { daily.hour_of_day(12) }
def perform def perform
HistoricalData.track! HistoricalData.track!
......
class LdapSyncWorker class LdapSyncWorker
include Sidekiq::Worker include Sidekiq::Worker
include Sidetiq::Schedulable
sidekiq_options retry: false sidekiq_options retry: false
if Gitlab.config.ldap.enabled
DAILY = Gitlab.config.ldap.schedule_sync_daily
HOUR = Gitlab.config.ldap.schedule_sync_hour
MINUTE = Gitlab.config.ldap.schedule_sync_minute
recurrence { daily(DAILY).hour_of_day(HOUR).minute_of_hour(MINUTE) }
end
def perform def perform
Rails.logger.info "Performing daily LDAP sync task." Rails.logger.info "Performing daily LDAP sync task."
User.ldap.find_each(batch_size: 100).each do |ldap_user| User.ldap.find_each(batch_size: 100).each do |ldap_user|
......
class UpdateAllMirrorsWorker class UpdateAllMirrorsWorker
include Sidekiq::Worker include Sidekiq::Worker
include Sidetiq::Schedulable
recurrence { hourly }
def perform def perform
Project.mirror.each(&:update_mirror) Project.mirror.each(&:update_mirror)
......
...@@ -170,13 +170,10 @@ production: &base ...@@ -170,13 +170,10 @@ production: &base
ldap: ldap:
enabled: false enabled: false
# GitLab EE only. #
# In addition to refreshing users when they log in, # Gitlab EE only:
# enabling this setting will refresh LDAP user membership once a day. # Since Gitlab 8.3, LDAP refresh job execution can be configured in schedule.yml
# Default time of the day when this will happen is at 1:30am server time. #
schedule_sync_daily: 1 # Run once every X days. Default: 1, meaning 'daily'
schedule_sync_hour: 1 # Hour of the day. Value from 0-23.
schedule_sync_minute: 30 # Minute of the hour. Value from 0-59.
servers: servers:
########################################################################## ##########################################################################
......
...@@ -21,7 +21,7 @@ Sidekiq.configure_server do |config| ...@@ -21,7 +21,7 @@ Sidekiq.configure_server do |config|
# Sidekiq-cron: load recurring jobs from schedule.yml # Sidekiq-cron: load recurring jobs from schedule.yml
schedule_file = 'config/schedule.yml' schedule_file = 'config/schedule.yml'
if File.exists?(schedule_file) if File.exists?(schedule_file)
Sidekiq::Cron::Job.load_from_hash YAML.load_file(schedule_file) Sidekiq::Cron::Job.load_from_hash YAML.load(ERB.new(File.read(schedule_file)).result)
end end
end end
......
...@@ -8,3 +8,27 @@ stuck_ci_builds_worker: ...@@ -8,3 +8,27 @@ stuck_ci_builds_worker:
cron: "0 0 * * *" cron: "0 0 * * *"
class: "StuckCiBuildsWorker" class: "StuckCiBuildsWorker"
queue: "default" queue: "default"
#
# GitLab EE only jobs:
#
historical_data_worker:
cron: "0 12 * * *"
class: "HistoricalDataWorker"
queue: "default"
update_all_mirrors_worker:
cron: "0 * * * *"
class: "UpdateAllMirrorsWorker"
queue: "default"
<% if Gitlab.config.ldap.enabled %>
# In addition to refreshing users when they log in,
# enabling this setting will refresh LDAP user membership once a day.
# Default time of the day when this will happen is at 1:30am server time.
ldap_sync_worker:
cron: "30 1 * * *"
class: "LdapSyncWorker"
queue: "default"
<% end %>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment