Skip to content

Commit

Permalink
Simplify logic to detect fluentd
Browse files Browse the repository at this point in the history
Co-authored-by: Daijiro Fukuda <[email protected]>
Signed-off-by: Kentaro Hayashi <[email protected]>
  • Loading branch information
kenhys and daipom committed Jun 28, 2024
1 parent 881cbdf commit feebdbe
Showing 1 changed file with 2 additions and 17 deletions.
19 changes: 2 additions & 17 deletions fluent-package/templates/usr/sbin/fluentd.erb
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,9 @@ if ARGV.include?("--version")
exit 0
end

class DuplicateInstanceChecker
def running_fluentd?
`systemctl is-active fluentd`
return true if $?.exitstatus == 0
false
end

def prevent_duplicate_launch?
unless running_fluentd?
return false
end
true
end
end

if RUBY_PLATFORM =~ /linux/
checker = DuplicateInstanceChecker.new
if checker.prevent_duplicate_launch?
prevent_duplicate_launch = system("systemctl", "is-active", "fluentd", out: IO::NULL)
if prevent_duplicate_launch
unless ARGV.include?("-c") or ARGV.include?("--config") or ARGV.include?("--dry-run")
puts("Error: Can't start duplicate Fluentd instance with the default config.")
if ARGV.include?("-v")
Expand Down

0 comments on commit feebdbe

Please sign in to comment.