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
|
# File 'app/controllers/deployed/log_output_controller.rb', line 7
def index
thread_exit_flag = false
thread = Thread.new do
File.open(current_log_file, 'r') do |file|
while true
IO.select([file])
found_deployed = false
file.each_line do |line|
if thread_exit_flag
break
end
css_class = if line.include?('[Deployed]')
'text-slate-400'
else
'text-green-400'
end
sse.write("<div class='#{css_class}'>#{line.strip}</div>", event: 'message')
if line.include?("[Deployed Rails] End")
found_deployed = true
break
end
end
if found_deployed || thread_exit_flag
break
end
end
end
end
begin
thread.join
rescue ActionController::Live::ClientDisconnected
logger.info 'Client Disconnected'
ensure
thread_exit_flag = true
sse.close
response.stream.close
end
end
|