27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
# File 'indexer/app/main.rb', line 27
def self.main
periodic_indexer = PeriodicIndexer.get_indexer
pui_indexer = PUIIndexer.get_indexer
threads = []
Log.info("Starting periodic indexer")
threads << Thread.new do
begin
periodic_indexer.run
rescue
Log.error("Unexpected failure in periodic indexer: #{$!}")
end
end
if AppConfig[:pui_indexer_enabled]
Log.info "Starting PUI indexer"
threads << Thread.new do
sleep AppConfig[:solr_indexing_frequency_seconds]
begin
pui_indexer.run
rescue
Log.error "Unexpected failure in PUI indexer: #{$!}"
end
end
end
sleep 5
backend_urls = Atomic.new([])
threads << Thread.new do
realtime_indexers = {}
while true
begin
backend_urls.update {|old_urls| AppConfig[:backend_instance_urls]}
backend_urls.value.each do |url|
if !realtime_indexers[url] || !realtime_indexers[url].alive?
Log.info "Starting realtime indexer for: #{url}"
realtime_indexers[url] = Thread.new do
begin
indexer = RealtimeIndexer.new(url, proc { backend_urls.value.include?(url) })
indexer.run
rescue
Log.error "Realtime indexing error (#{backend_url}): #{$!}"
sleep 5
end
end
end
end
sleep 60
rescue
sleep 5
end
end
end
threads.each {|t| t.join} if java.lang.System.get_property("aspace.devserver")
end
|