Skip to content

Commit

Permalink
[webui] avoid hanging live log page, when the worker allows TCP conne…
Browse files Browse the repository at this point in the history
…ct, but does not deliver data
  • Loading branch information
adrianschroeter committed Jun 17, 2014
1 parent 137452a commit 99bedbd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
9 changes: 6 additions & 3 deletions src/api/app/controllers/webui/package_controller.rb
Expand Up @@ -766,20 +766,21 @@ def live_build_log
end
@arch = params[:arch]
@repo = params[:repository]
@offset = 0

set_job_status
end

def set_initial_offset
# Do not start at the beginning long time ago
begin
size = get_size_of_log(@project, @package, @repo, @arch)
logger.debug('log size is %d' % size)
@offset = size - 32 * 1024
@offset = 0 if @offset < 0
@initiallog = get_log_chunk( @project, @package, @repo, @arch, @offset, size)
rescue => e
logger.error "Got #{e.class}: #{e.message}; returning empty log."
@initiallog = ''
end
@offset = (@offset || 0) + ActiveXML::backend.last_body_length
end

def update_build_log
Expand All @@ -794,6 +795,8 @@ def update_build_log
@finished = false
@maxsize = 1024 * 64

set_initial_offset if @offset == 0

begin
@log_chunk = get_log_chunk( @project, @package, @repo, @arch, @offset, @offset + @maxsize)

Expand Down
4 changes: 2 additions & 2 deletions src/api/app/views/webui/package/live_build_log.html.erb
Expand Up @@ -22,10 +22,10 @@
data-url="<%= url_for(action: :update_build_log,
package: @package, project: @project,
arch: @arch, repository: @repo) %>">
<pre id="log_space"><%= raw @initiallog %></pre>
<pre id="log_space"></pre>
</div>

<% if not @initiallog.empty? %>
<% if not @workerid %>
<%= render :partial => "live_log_controls" %>
<% end %>

0 comments on commit 99bedbd

Please sign in to comment.