Commit 2e0fb146 authored by Valery Sizov's avatar Valery Sizov

[ES] logging for indexer

parent 86999717
Please view this file on the master branch, on stable branches it's out of date. Please view this file on the master branch, on stable branches it's out of date.
v 8.11.3
- [ES] Add logging to indexer
v 8.11.0 (unreleased) v 8.11.0 (unreleased)
- Allow projects to be moved between repository storages - Allow projects to be moved between repository storages
......
...@@ -6,6 +6,10 @@ require 'json' ...@@ -6,6 +6,10 @@ require 'json'
require 'elasticsearch/git' require 'elasticsearch/git'
require 'active_support' require 'active_support'
require 'active_support/core_ext' require 'active_support/core_ext'
require 'benchmark'
path_to_log_file = File.expand_path('../../log/es-indexer.log', __FILE__)
LOGGER = Logger.new(path_to_log_file)
PROJECT_ID = ARGV.shift PROJECT_ID = ARGV.shift
REPO_PATH = ARGV.shift REPO_PATH = ARGV.shift
...@@ -13,6 +17,8 @@ FROM_SHA = ENV['FROM_SHA'] ...@@ -13,6 +17,8 @@ FROM_SHA = ENV['FROM_SHA']
TO_SHA = ENV['TO_SHA'] TO_SHA = ENV['TO_SHA']
RAILS_ENV = ENV['RAILS_ENV'] RAILS_ENV = ENV['RAILS_ENV']
LOGGER.info("[ES indexer]: Has been scheduled for project #{REPO_PATH} with SHA range #{FROM_SHA}:#{TO_SHA}")
elastic_connection_info = JSON.parse ENV['ELASTIC_CONNECTION_INFO'] elastic_connection_info = JSON.parse ENV['ELASTIC_CONNECTION_INFO']
ELASTIC_HOST = elastic_connection_info['host'] ELASTIC_HOST = elastic_connection_info['host']
ELASTIC_PORT = elastic_connection_info['port'] ELASTIC_PORT = elastic_connection_info['port']
...@@ -45,9 +51,21 @@ repo = Repository.new ...@@ -45,9 +51,21 @@ repo = Repository.new
params = { from_rev: FROM_SHA, to_rev: TO_SHA }.compact params = { from_rev: FROM_SHA, to_rev: TO_SHA }.compact
print "Indexing commits..." print "Indexing commits..."
repo.index_commits(params)
timings = Benchmark.measure do
repo.index_commits(params)
end
puts "Done" puts "Done"
LOGGER.info("[ES indexer]: Commits for #{REPO_PATH} are indexed. Time elapsed: #{timings.real}")
print "Indexing blobs..." print "Indexing blobs..."
repo.index_blobs(params)
timings = Benchmark.measure do
repo.index_blobs(params)
end
puts "Done" puts "Done"
LOGGER.info("[ES indexer]: Blobs for #{REPO_PATH} are indexed. Time elapsed: #{timings.real}")
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