Skip to content

Commit

Permalink
add prune_resque_workers API
Browse files Browse the repository at this point in the history
  • Loading branch information
brianlball committed Aug 10, 2024
1 parent 6530523 commit b00258f
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
14 changes: 14 additions & 0 deletions server/app/controllers/admin_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,20 @@ def index
@os_cli = version ? version.strip : 'Unknown'
end

def prune_resque_workers
Rails.logger.warn "Pruning Dead Resque Workers"

# Enqueue a new job
worker = Resque::Worker.new()
worker.prune_dead_workers
worker.shutdown

respond_to do |format|
format.html { redirect_to admin_index_path, notice: 'Resque Workers Pruned.' }
format.json { head :no_content }
end
end

def backup_database
logger.info params
write_and_send_data
Expand Down
2 changes: 1 addition & 1 deletion server/app/controllers/data_points_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ def result_files
end

def requeue
Rails.logger.warn "data_points_contoller.REQUEUE"
Rails.logger.warn "data_points_contoller.REQUEUEing #{@data_point.id}"
@data_point = DataPoint.find(params[:id])
analysis_id = @data_point.analysis
Rails.logger.debug "data_points_contoller.id: #{@data_point.id}"
Expand Down
4 changes: 4 additions & 0 deletions server/app/views/admin/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
<!-- TODO: How to test if this exists when on Windows -->
<%= link_to 'View Resque Dashboard', resque_web_path, class: "btn btn-mini btn-primary" %>
</div>
<div class="span3 pad-bottom-20">
<!-- Link to prune dead Resque workers -->
<%= link_to 'Prune Dead Resque Workers', prune_resque_workers_admin_index_path, method: :post, class: "btn btn-mini btn-danger", data: { confirm: 'Are you sure you want to prune dead Resque workers?' } %>
</div>
</div>
<% end %>

Expand Down
1 change: 1 addition & 0 deletions server/config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@
collection do
get :backup_database
post :restore_database
post :prune_resque_workers
end
end

Expand Down

0 comments on commit b00258f

Please sign in to comment.