Skip to content
This repository has been archived by the owner on Dec 19, 2019. It is now read-only.

nbproc': undefined method []' for nil:NilClass (NoMethodError) #27

Open
bizmurr opened this issue Feb 27, 2015 · 10 comments
Open

nbproc': undefined method []' for nil:NilClass (NoMethodError) #27

bizmurr opened this issue Feb 27, 2015 · 10 comments

Comments

@bizmurr
Copy link

bizmurr commented Feb 27, 2015

Hi, with the latest release I get this error when running sudo service haproxyctl show health:

/usr/local/haproxyctl/bin/../lib/haproxyctl/environment.rb:42:in `nbproc': undefined method `[]' for nil:NilClass (NoMethodError)
        from /usr/local/haproxyctl/bin/../lib/haproxyctl/environment.rb:52:in `socket'
        from /usr/local/haproxyctl/bin/../lib/haproxyctl.rb:55:in `unixsock'
        from /etc/init.d/haproxyctl:105

Everything works fine on 1.3.0, I am using CentOS 6.5.

@OliverKellyATech
Copy link

Just adding a +1 to this issue, as we are also seeing it in out environment.

@shaynem
Copy link

shaynem commented May 19, 2015

I had the same issue, looking at the code it's wanting to parse the nbproc directive from the haproxy.cfg file

The stats socket will only work with nbproc 1 as far as i can tell, once you add nbproc 1 to the config file it will resolve this issue. p.s without this directive haproxy defaults to 1 anyway

1.5) Increasing the overall processing power

On multi-processor systems, it may seem to be a shame to use only one processor,
eventhough the load needed to saturate a recent processor is far above common
usage. Anyway, for very specific needs, the proxy can start several processes
between which the operating system will spread the incoming connections. The
number of processes is controlled by the 'nbproc' parameter in the 'global'
section. It defaults to 1, and obviously works only in 'daemon' mode. One
typical usage of this parameter has been to workaround the default per-process
file-descriptor limit that Solaris imposes to user processes.

Example :

global
    daemon
    quiet
    nbproc  2

@jayhilden
Copy link

@shaynem we are running into this same issue on the latest (1.3.0) release and we are NOT specifying nbproc. Do you have any recommendations for us?

Haproxy version 1.5.2
HaProxyCTL 1.3.0
RedHatEnterpriseServer 6.6

$ sudo haproxyctl show status
/usr/lib/ruby/gems/1.8/gems/haproxyctl-1.3.0/bin/../lib/haproxyctl/environment.rb:42:in `socket': undefined method `[]' for nil:NilClass (NoMethodError)
        from /usr/lib/ruby/gems/1.8/gems/haproxyctl-1.3.0/bin/../lib/haproxyctl.rb:55:in `unixsock'
        from /usr/lib/ruby/gems/1.8/gems/haproxyctl-1.3.0/bin/haproxyctl:174
        from /usr/bin/haproxyctl:19:in `load'
        from /usr/bin/haproxyctl:19

We also get this error when we try to remove a backend (which is a primary use case for us with haproxyctl).

$ sudo haproxyctl disable server back_fortest/PIRATE
/usr/lib/ruby/gems/1.8/gems/haproxyctl-1.3.0/bin/../lib/haproxyctl/environment.rb:42:in `socket': undefined method `[]' for nil:NilClass (NoMethodError)
        from /usr/lib/ruby/gems/1.8/gems/haproxyctl-1.3.0/bin/../lib/haproxyctl.rb:55:in `unixsock'
        from /usr/lib/ruby/gems/1.8/gems/haproxyctl-1.3.0/bin/haproxyctl:174
        from /usr/bin/haproxyctl:19:in `load'
        from /usr/bin/haproxyctl:19

CC: @mnmexy

@lewisst
Copy link

lewisst commented Jul 30, 2015

@jayhilden you need to add a socket line to your /etc/haproxy/haproxy.cfg

under the global section add something similar to:

    stats socket /run/haproxy/admin.sock mode 660 level admin
    stats timeout 30s

@jayhilden
Copy link

@lewisst thank you very much, that corrected the first half of the issue issue. Now when I try to reload I get an error surrounding that file (I choose to name it /var/run/haproxy.stat vs admin.sock). It says it's waiting but it never returns.

If I run this as root with sudo it works fine.

Any advice on this would be much appreciated.

jhilden@prism:/var/run$ haproxyctl reload
gracefully stopping connections on pid 28360...
[WARNING] 210/154027 (29472) : [/usr/sbin/haproxy.main()] Cannot raise FD limit to 120089.
[ALERT] 210/154027 (29472) : Starting frontend GLOBAL: error when trying to preserve previous UNIX socket [/var/run/haproxy.stat]
checking if connections still alive on 28360...
still haven't killed old pid.
                            waiting 2s for existing connections to die...
                            (ctrl+c to stop this check)
still haven't killed old pid.
                            waiting 2s for existing connections to die...
                            (ctrl+c to stop this check)
^C/usr/lib/ruby/gems/1.8/gems/haproxyctl-1.3.0/bin/../lib/haproxyctl.rb:41:in `sleep': Interrupt
        from /usr/lib/ruby/gems/1.8/gems/haproxyctl-1.3.0/bin/../lib/haproxyctl.rb:41:in `reload'
        from /usr/lib/ruby/gems/1.8/gems/haproxyctl-1.3.0/bin/haproxyctl:57
        from /usr/bin/haproxyctl:19:in `load'
        from /usr/bin/haproxyctl:19

@tersmitten
Copy link

We have the same problem:

  stats socket /run/haproxy/admin.sock mode 660 level admin
  stats bind-process 1
  stats timeout 30s
  ...
  nbproc 8

Results in this error:

# /etc/init.d/haproxyctl show health
/var/lib/ansible/haproxyctl/checkouts/haproxyctl/lib/haproxyctl/environment.rb:57:in `socket': undefined method `[]' for nil:NilClass (NoMethodError)
    from /var/lib/ansible/haproxyctl/checkouts/haproxyctl/lib/haproxyctl.rb:55:in `unixsock'
    from /etc/init.d/haproxyctl:105:in `<main>'

@tersmitten
Copy link

Changing our configuration to:

  stats socket /run/haproxy/admin-1.sock mode 660 level admin process 1
  stats socket /run/haproxy/admin-2.sock mode 660 level admin process 2
  stats socket /run/haproxy/admin-3.sock mode 660 level admin process 3
  stats socket /run/haproxy/admin-4.sock mode 660 level admin process 4
  stats socket /run/haproxy/admin-5.sock mode 660 level admin process 5
  stats socket /run/haproxy/admin-6.sock mode 660 level admin process 6
  stats socket /run/haproxy/admin-7.sock mode 660 level admin process 7
  stats socket /run/haproxy/admin-8.sock mode 660 level admin process 8

Fixed the problem for us.

@FlorinAndrei
Copy link

Same error here with haproxyctl-1.4.3 and haproxy-1.6.3
haproxyctl-1.3.0 used to work just fine.

It errors out unless nbproc 1 is specified in the global section. Seems like a weird dependency, since nbproc is a rarely used config item, and it's entirely optional.

haproxyctl should handle the absence of the non-mandatory nbproc gracefully. Don't error out, just keep working as before.

@makdisse
Copy link

+1

1 similar comment
@Heliosmaster
Copy link

👍

pkolmann added a commit to pkolmann/haproxyctl that referenced this issue May 13, 2016
tersmitten added a commit to tersmitten/haproxyctl that referenced this issue Aug 18, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants