blob: 77e7a454bc9b31483c9c0365c870c32638d12742 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
class ClearSharedRunnersMinutesWorker
LEASE_TIMEOUT = 3600
include Sidekiq::Worker
include CronjobQueue
def perform
return unless try_obtain_lease
ProjectStatistics.update_all(
shared_runners_seconds: 0,
shared_runners_seconds_last_reset: Time.now)
NamespaceStatistics.update_all(
shared_runners_seconds: 0,
shared_runners_seconds_last_reset: Time.now)
end
private
def try_obtain_lease
Gitlab::ExclusiveLease.new('gitlab_clear_shared_runners_minutes_worker',
timeout: LEASE_TIMEOUT).try_obtain
end
end
|