From 8dd0d5ad84f94fc33a423bcc681cf314777199d2 Mon Sep 17 00:00:00 2001 From: Pedro Chambino Date: Fri, 1 Mar 2024 16:01:29 +0000 Subject: [PATCH] Continue even if Process.setpgrp fails In CircleCI, calling Process.setpgrp raises an "Operation not permitted" error, but other than that flatware works. In this change, we allow flatware to continue when the error is raised. If flatware is executed with --log, then it will print: INFO -- : flatware sink continuing after: Process.setpgrp: Operation not permitted At Carwow, we have been running flatware on CircleCI for about 1 month (with a monkey-patched Process.setpgrp) and it works great! It allowed Carwow to reduce CircleCI credits by half, and also our Docker Hub pulls. --- lib/flatware/cli.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/flatware/cli.rb b/lib/flatware/cli.rb index 4dad80e..6ea47d1 100644 --- a/lib/flatware/cli.rb +++ b/lib/flatware/cli.rb @@ -55,7 +55,8 @@ def clear def start_sink(jobs:, workers:, formatter:) $0 = 'flatware sink' - Process.setpgrp + try_setpgrp + passed = Sink.start_server( jobs: jobs, formatter: Flatware::Broadcaster.new([formatter]), @@ -65,6 +66,12 @@ def start_sink(jobs:, workers:, formatter:) exit passed ? 0 : 1 end + def try_setpgrp + Process.setpgrp + rescue Errno::EPERM => e + Flatware.log 'continuing after: Process.setpgrp:', e.message + end + def workers options[:workers] end