Class: KPM::NodesInfoController
- Inherits:
-
EngineController
show all
- Includes:
- ActionController::Live
- Defined in:
- app/controllers/kpm/nodes_info_controller.rb
Instance Method Summary
collapse
#current_tenant_user, #get_layout, #options_for_klient
Instance Method Details
#index ⇒ Object
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'app/controllers/kpm/nodes_info_controller.rb', line 10
def index
@installing = !params[:i].blank?
@nodes_info = ::KillBillClient::Model::NodesInfo.nodes_info(options_for_klient)
@nodes_info.each do |node_info|
next if node_info.plugins_info.nil?
node_info.plugins_info.sort! do |a, b|
if osgi_bundle?(a) && !osgi_bundle?(b)
1
elsif !osgi_bundle?(a) && osgi_bundle?(b)
-1
else
a.plugin_name <=> b.plugin_name
end
end
end
@kb_host = params[:kb_host] || KillBillClient::API.base_uri
@last_event_id = params[:last_event_id]
end
|
#install_plugin ⇒ Object
79
80
81
82
|
# File 'app/controllers/kpm/nodes_info_controller.rb', line 79
def install_plugin
trigger_node_plugin_command('INSTALL_PLUGIN')
redirect_to nodes_info_index_path(i: 1)
end
|
#refresh ⇒ Object
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
|
# File 'app/controllers/kpm/nodes_info_controller.rb', line 34
def refresh
response.['Content-Type'] = 'text/event-stream'
last_event_id_ref = Concurrent::AtomicReference.new(request.['Last-Event-Id'] || params[:last_event_id])
sse = nil
sse_client = nil
begin
sse = ActionController::Live::SSE.new(response.stream, retry: 300, event: 'refresh')
sse_client = ::Killbill::KPM::KPMClient.stream_osgi_logs(sse, params[:kb_host], last_event_id_ref)
i = 0
while i < 6 i += 1
sse.write('heartbeat', id: last_event_id_ref.get)
sleep 5
end
rescue ActionController::Live::ClientDisconnected
ensure
begin
begin
sse_client&.close
rescue StandardError
end
sse&.close
ensure
ActiveRecord::Base.connection_pool.reap
end
end
end
|
#restart_plugin ⇒ Object
99
100
101
102
|
# File 'app/controllers/kpm/nodes_info_controller.rb', line 99
def restart_plugin
trigger_node_plugin_command('RESTART_PLUGIN')
head :ok
end
|
#start_plugin ⇒ Object
89
90
91
92
|
# File 'app/controllers/kpm/nodes_info_controller.rb', line 89
def start_plugin
trigger_node_plugin_command('START_PLUGIN')
head :ok
end
|
#stop_plugin ⇒ Object
94
95
96
97
|
# File 'app/controllers/kpm/nodes_info_controller.rb', line 94
def stop_plugin
trigger_node_plugin_command('STOP_PLUGIN')
head :ok
end
|
#uninstall_plugin ⇒ Object
84
85
86
87
|
# File 'app/controllers/kpm/nodes_info_controller.rb', line 84
def uninstall_plugin
trigger_node_plugin_command('UNINSTALL_PLUGIN')
head :ok
end
|