7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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
97
98
99
100
101
102
103
104
105
106
107
108
|
# File 'lib/legate/web/routes/core_routes.rb', line 7
def self.registered(app)
app.get '/' do
logger.debug('GET / route handler entered (from CoreRoutes)')
definition_store = instance_variable_get(:@definition_store)
tool_manager = instance_variable_get(:@tool_manager)
@agent_count = 0
@running_count = 0
@tool_count = 0
@auth_scheme_count = 0
if definition_store
definitions = begin
definition_store.list_definitions
rescue StandardError
[]
end
@agent_count = definitions.size
end
active_agents_hash = instance_variable_get(:@agents)
@running_count = active_agents_hash&.size || 0
if tool_manager
@tool_count = begin
tool_manager.tools.size
rescue StandardError
0
end
end
@auth_scheme_count = begin
Legate::Auth::Manager.instance.schemes.size
rescue StandardError
0
end
@recent_activity = if defined?(Legate::ActivityLog)
begin
Legate::ActivityLog.recent(8)
rescue StandardError
[]
end
else
[]
end
slim :index
end
app.get '/activity/recent' do
@recent_activity = if defined?(Legate::ActivityLog)
begin
Legate::ActivityLog.recent(8)
rescue StandardError
[]
end
else
[]
end
slim :_activity_list, layout: false
end
app.get '/healthz' do
current_app_instance = self
definition_store = current_app_instance.instance_variable_get(:@definition_store)
store_ok = if definition_store
definition_store.check_connection
else
true end
unless store_ok
logger.error('Health check failed: Definition Store unavailable or connection failed (from CoreRoutes).')
status 503
body 'Service Unavailable (Persistence)'
return
end
status 200
body 'OK'
rescue Legate::DefinitionStore::StoreError => e
logger.error("Health check failed (from CoreRoutes): Store error - #{e.message}")
status 503
body 'Service Unavailable (Persistence Error)'
rescue StandardError => e logger.error("Health check failed (from CoreRoutes): Unexpected error - #{e.class}: #{e.message}")
status 503
body 'Service Unavailable (Internal)'
end
end
|