From a7a8de331e56badd2a35316c3344f6804faca1b2 Mon Sep 17 00:00:00 2001 From: Toon Claes Date: Thu, 11 Apr 2019 22:49:05 +0200 Subject: [PATCH 1/3] Move bin/geo_log_cursor to ee/bin To decrease the diff between CE & EE even further, move the EE-only bin script for the Geo log cursor to ee/bin. --- {bin => ee/bin}/geo_log_cursor | 11 ++++++++--- ee/changelogs/unreleased/tc-move-geo-cursor-bin.yml | 5 +++++ 2 files changed, 13 insertions(+), 3 deletions(-) rename {bin => ee/bin}/geo_log_cursor (80%) create mode 100644 ee/changelogs/unreleased/tc-move-geo-cursor-bin.yml diff --git a/bin/geo_log_cursor b/ee/bin/geo_log_cursor similarity index 80% rename from bin/geo_log_cursor rename to ee/bin/geo_log_cursor index a4acf71fa84f5e..69a6b89ff4dddd 100755 --- a/bin/geo_log_cursor +++ b/ee/bin/geo_log_cursor @@ -1,9 +1,14 @@ #!/usr/bin/env ruby -# vim: ft=ruby +# frozen_string_literal: true + require 'rubygems' require 'bundler/setup' require 'optparse' +def rails_path(relname) + Pathname.new(__FILE__).dirname.join('../..').join(relname).realpath +end + class GeoLogCursorOptionParser def self.parse(argv) options = {} @@ -22,7 +27,7 @@ class GeoLogCursorOptionParser end op.on('-v', '--version') do # Load only necessary libraries for faster startup - require "#{File.dirname(__FILE__)}/../lib/gitlab/geo/log_cursor/daemon" + require rails_path('ee/lib/gitlab/geo/log_cursor/daemon.rb') puts Gitlab::Geo::LogCursor::Daemon::VERSION exit @@ -39,7 +44,7 @@ if $0 == __FILE__ options = GeoLogCursorOptionParser.parse(ARGV) # We load rails environment / initializers only here to get faster command line startup when `--help` and `--version` - require "#{File.dirname(__FILE__)}/../config/environment" + require rails_path('config/environment.rb') Gitlab::Geo::LogCursor::Daemon.new(options).run! end diff --git a/ee/changelogs/unreleased/tc-move-geo-cursor-bin.yml b/ee/changelogs/unreleased/tc-move-geo-cursor-bin.yml new file mode 100644 index 00000000000000..a40cde834984d3 --- /dev/null +++ b/ee/changelogs/unreleased/tc-move-geo-cursor-bin.yml @@ -0,0 +1,5 @@ +--- +title: Move geo_log_cursor binary to the ee folder +merge_request: 10821 +author: +type: other -- GitLab From dfe32d34a014ad0239e5d56c4831cb01df9fbdf3 Mon Sep 17 00:00:00 2001 From: Toon Claes Date: Thu, 11 Apr 2019 22:50:04 +0200 Subject: [PATCH 2/3] Fix geo_log_cursor --version There were some dependencies which weren't loaded when running `bin/geo_log_cursor --version`. So refactor those and fix the version command. --- ee/lib/gitlab/geo/log_cursor/daemon.rb | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/ee/lib/gitlab/geo/log_cursor/daemon.rb b/ee/lib/gitlab/geo/log_cursor/daemon.rb index 1c548ce7a16f4d..cc9c3eb51241f9 100644 --- a/ee/lib/gitlab/geo/log_cursor/daemon.rb +++ b/ee/lib/gitlab/geo/log_cursor/daemon.rb @@ -4,11 +4,9 @@ module Gitlab module Geo module LogCursor class Daemon - include Utils::StrongMemoize - VERSION = '0.2.0'.freeze BATCH_SIZE = 250 - SECONDARY_CHECK_INTERVAL = 1.minute + SECONDARY_CHECK_INTERVAL = 60 attr_reader :options @@ -130,9 +128,7 @@ def gap_tracking end def logger - strong_memoize(:logger) do - Gitlab::Geo::LogCursor::Logger.new(self.class, log_level) - end + @logger ||= Gitlab::Geo::LogCursor::Logger.new(self.class, log_level) end def log_level -- GitLab From 77e0ff4c11b150222bc227ed1fb36aafc1f5d78c Mon Sep 17 00:00:00 2001 From: Toon Claes Date: Fri, 12 Apr 2019 10:34:51 +0200 Subject: [PATCH 3/3] Exclude ee/bin from Naming/FileName cop --- .rubocop.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.rubocop.yml b/.rubocop.yml index 8be3fdd2307774..2a180ad20cb0b9 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -77,6 +77,7 @@ Naming/FileName: - 'qa/spec/**/*' - 'qa/qa/specs/**/*' - 'qa/bin/*' + - 'ee/bin/*' - 'config/**/*' - 'ee/config/**/*' - 'lib/generators/**/*' -- GitLab