From f56a7377a9dff2ecc949265692df040542e69adb Mon Sep 17 00:00:00 2001 From: Guus Houtzager Date: Mon, 16 Feb 2015 15:54:48 +0100 Subject: [PATCH] Fix issues when nbproc is not present in haproxy.cfg. Prevents this error: ../lib/haproxyctl/environment.rb:42:in []' for nil:NilClass (NoMethodError) from /usr/local/sbin/../lib/haproxyctl/environment.rb:52:in unixsock' from ./haproxyctl:105 --- lib/haproxyctl/environment.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/haproxyctl/environment.rb b/lib/haproxyctl/environment.rb index aee53fd..a522319 100644 --- a/lib/haproxyctl/environment.rb +++ b/lib/haproxyctl/environment.rb @@ -38,8 +38,11 @@ def exec def nbproc @nbproc ||= begin - config.match /nbproc \s*(\d*)\s*/ - Regexp.last_match[1].to_i || 1 + if config.match(/nbproc \s*(\d*)\s*/) + Regexp.last_match[1].to_i + else + 1 + end end end