From 131b9a3bbd99a294a7ac8b30568e6f037bf99e11 Mon Sep 17 00:00:00 2001 From: Facundo Farias Date: Sat, 12 Sep 2026 12:36:02 +0200 Subject: [PATCH] Suggest check_concurrency when status reports an incorrect quantity `procodile status` reports when a process type is below its configured quantity: * worker only has 23 instances (should have 25) but does not say how to fix it. The remedy is `procodile check_concurrency`, which is easy to miss: `procodile start ` looks like the obvious candidate but is a no-op here, because start_processes skips any type that already has running instances. Print a follow-up line naming the command whenever an incorrect_quantity message is present. This is deliberately added to StatusCLIOutput rather than Message.parse, because Message.parse also backs `procodile status --simple`, whose one-line output is typically consumed by monitoring and should stay terse. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_01P89F451YDRDBj5br14i3GD --- lib/procodile/status_cli_output.rb | 3 ++ spec/specs/status_cli_output_spec.rb | 58 ++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 spec/specs/status_cli_output_spec.rb diff --git a/lib/procodile/status_cli_output.rb b/lib/procodile/status_cli_output.rb index 24946a4..21e2101 100644 --- a/lib/procodile/status_cli_output.rb +++ b/lib/procodile/status_cli_output.rb @@ -36,6 +36,9 @@ def print_header for message in @status['messages'] puts "\e[31m * #{Message.parse(message)}\e[0m" end + if @status['messages'].any? { |message| message['type'] == 'incorrect_quantity' } + puts "\e[33m Run `procodile check_concurrency` to start the missing process(es).\e[0m" + end end end diff --git a/spec/specs/status_cli_output_spec.rb b/spec/specs/status_cli_output_spec.rb new file mode 100644 index 0000000..a564b53 --- /dev/null +++ b/spec/specs/status_cli_output_spec.rb @@ -0,0 +1,58 @@ +require 'spec_helper' +require 'procodile/status_cli_output' + +describe Procodile::StatusCLIOutput do + def status_with(messages) + { + 'version' => '1.0.27', + 'root' => '/apps/example', + 'supervisor' => {'pid' => 100, 'started_at' => nil}, + 'environment_variables' => {}, + 'messages' => messages + } + end + + let(:incorrect_quantity) do + {'type' => 'incorrect_quantity', 'process' => 'worker', 'current' => 23, 'desired' => 25} + end + + let(:not_running) do + {'type' => 'not_running', 'instance' => 'worker.1', 'status' => 'Failed'} + end + + context "when a process is below its configured quantity" do + subject(:cli) { described_class.new(status_with([incorrect_quantity])) } + + it "still prints the underlying message" do + expect { cli.print_header }.to output(/worker only has 23 instances \(should have 25\)/).to_stdout + end + + it "suggests check_concurrency as the remedy" do + expect { cli.print_header }.to output(/procodile check_concurrency/).to_stdout + end + end + + context "when the only messages are unrelated to quantity" do + subject(:cli) { described_class.new(status_with([not_running])) } + + it "does not suggest check_concurrency" do + expect { cli.print_header }.to_not output(/check_concurrency/).to_stdout + end + end + + context "when there are no messages at all" do + subject(:cli) { described_class.new(status_with([])) } + + it "does not suggest check_concurrency" do + expect { cli.print_header }.to_not output(/check_concurrency/).to_stdout + end + end + + context "when quantity and other messages are both present" do + subject(:cli) { described_class.new(status_with([not_running, incorrect_quantity])) } + + it "suggests check_concurrency only once" do + expect { cli.print_header }.to output(/check_concurrency/).to_stdout + end + end +end