Skip to main content

supervisor eventlistener for notifying haproxy

Project description

supervisor-haproxy

supervisor-haproxy is a supervisor event listener for notifying HaProxy when the status of programs change.

By actively notifying HaProxy we can avoid that HaProxy sends requests to servers which are down or will be down shortly for maintenance.

The event listener listens to supervisors PROCESS_STATE events and sends status updates to HaProxy via an admin-level stats socket.

Configuration

When the egg supervisor-haproxy is installed, the supervisor event listener is created as console script supervisor-haproxy. It needs to be configured in the supervisor configuration and requires the haproxy stats socket and the program infos in order to work correctly.

The program infos have the form supervisorProgram:HaProxyBackend/HaProxyServer, for example instance2:plone04/plone0402 and tell the event listener which program in supervisor is which backend server in haproxy.

First configure a stats socket in the haproxy config:

global
    stats socket ipv4@127.0.0.1:8801 level admin

then configure the supervisor haproxy event listener in the supervisor config:

[eventlistener:HaProxy]
command = .../bin/supervisor-haproxy tcp://localhost:8801 instance1:plone01/plone0101 instance2:plone01/plone0102
events = PROCESS_STATE
process_name=HaProxy

Example using buildout for configuring supervisor:

[supervisor]
plugins +=
    supervisor-haproxy
eventlisteners +=
    HaProxy PROCESS_STATE ${buildout:bin-directory}/supervisor-haproxy [tcp://localhost:8801 instance1:plone01/plone0101 instance2:plone01/plone0102]

Development / Tests

For development and running tests you need to install:

  • tox in order to run the tests.

  • docker so that the tests can set up a haproxy for testing against.

After installing tox and docker you can clone the repository and run the tests with the tox command:

$ git clone git@github.com:4teamwork/supervisor-haproxy.git
$ cd supervisor-haproxy
$ tox

While running the tests, the haproxy in docker will be bound to the port 9902, so you need to make sure that this port is available.

Changelog

1.1.0 (2017-06-09)

  • Avoid high CPU load problem when connection to HaProxy fails. [jone]

1.0.0 (2016-09-30)

  • Initial implementation [jone]

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

supervisor-haproxy-1.1.0.tar.gz (15.5 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page