Skip to content

Commit

Permalink
Show basename of proctitle (#679)
Browse files Browse the repository at this point in the history
* Show basename of proctitle

* Show full proctitle in title attribute

* Fix lint error in spec
  • Loading branch information
bkeepers authored Jul 26, 2022
1 parent ef97c10 commit d67d677
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
6 changes: 3 additions & 3 deletions app/views/good_job/processes/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
<div id="<%= dom_id(process) %>" class="<%= dom_class(process) %> list-group-item py-3" role="row">
<div class="row align-items-center">
<div class="col">
<code class="font-monospace">
<%= tag.code title: process.state['proctitle'], class: "font-monospace" do %>
<span class="text-muted opacity-50">$</span>
<%= process.state["proctitle"] %>
</code>
<%= process.basename %>
<% end %>
<div>
<span class="text-muted small">PID</span>
<span class="badge rounded-pill bg-light text-dark"><%= process.state["pid"] %></span>
Expand Down
4 changes: 4 additions & 0 deletions lib/models/good_job/process.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,9 @@ def deregister
destroy!
advisory_unlock
end

def basename
File.basename(state["proctitle"])
end
end
end
14 changes: 14 additions & 0 deletions spec/lib/models/good_job/process_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,18 @@
expect { process.deregister }.to change(described_class, :count).by(-1)
end
end

describe '#basename' do
let(:process) { described_class.new state: {} }

it 'splits proctitle on dir and program name' do
process.state['proctitle'] = '/app/bin/good_job'
expect(process.basename).to eq('good_job')
end

it 'preserves program arguments' do
process.state['proctitle'] = '/Users/me/projects/good_job/bin/bundle exec rails start'
expect(process.basename).to eq('bundle exec rails start')
end
end
end

0 comments on commit d67d677

Please sign in to comment.