Skip to main content

Build Status Coverage Status

ianitor

ianitor is a doorkeeper for your services discovered using consul. It can automatically register new services through consul API and manage TTL health checks.

It provides simple shell command that wraps process and can be simply used in your existing process/service supervision tool like supervisord, circus, runit etc.

Consul/Python versions compatibility

ianitor is compatibile with Python 2.7, 3.3, 3.4, and 3.5 versions. It is also tested against each latest patch version of every major/minor consul release starting from 0.4.1 version.

For details of our test matrix see travis.yml file.

Installation and usage

Simply install with pip:

$ pip install ianitor

And you're ready to go with:

$ ianitor appname -- ./yourapp --some-switch

You can check if service is registered diggin' into consul DNS service:

$ dig @localhost -p 8600 appname.service.consul
; <<>> DiG 9.9.3-P1 <<>> @localhost -p 8600 appname.service.consul
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 25966
;; flags: qr aa rd; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
;; WARNING: recursion requested but not available

;; QUESTION SECTION:
;appname.service.consul.		IN	A

;; ANSWER SECTION:
appname.service.consul.	0	IN	A	10.54.54.214

;; Query time: 44 msec
;; SERVER: 127.0.0.1#8600(127.0.0.1)
;; WHEN: Tue Oct 28 13:53:09 CET 2014
;; MSG SIZE  rcvd: 78

Full usage:

usage: ianitor [-h] [--consul-agent hostname[:port]] [--ttl seconds]
               [--heartbeat seconds] [--tags tag] [--id ID] [--port PORT] [-v]
               service-name -- command [arguments]

Doorkeeper for consul discovered services.

positional arguments:
  service-name                    service name in consul cluster

optional arguments:
  -h, --help                      show this help message and exit
  --consul-agent=hostname[:port]  set consul agent address
  --ttl=seconds                   set TTL of service in consul cluster
  --heartbeat=seconds             set process poll heartbeat (defaults to
                                  ttl/10)
  --tags=tag                      set service tags in consul cluster (can be
                                  used multiple times)
  --id=ID                         set service id - must be node unique
                                  (defaults to service name)
  --port=PORT                     set service port
  -v, --verbose                   enable logging to stdout (use multiple times
                                  to increase verbosity)

How does ianitor work?

ianitor spawns process using python's subprocess.Popen() with command line specified after -- . It redirects its own stdin to child's stdin and childs stdout/stderr to his own stdout/stderr.

This way ianitor does not interfere with logging of managed service if it logs to stdout. Moreover ianitor does not log anything to make it easier to plug it in your existing process supervision tool.

ianitor handles service registration in consul agent as well as keeping registered service entry in consul in "healthy" state by continously requesting it's TTL health check endpoint.

Example supervisord config

Assuming that you have some service under supervisord supervision:

[program:rabbitmq]
command=/usr/sbin/rabbitmq-server
priority=0

autostart=true

Simply wrap it with ianitor call:

[program:rabbitmq]
command=/usr/local/bin/ianitor rabbitmq -- /usr/sbin/rabbitmq-server
priority=0

autostart=true

Licence

ianitor is licensed under LGPL license, version 3.

Contributing and reporting bugs

Source code is available at: ClearcodeHQ/ianitor. Issue tracker is located at GitHub Issues. Projects PyPi page.

Release files for ianitor 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ianitor 0.1.0
File Size Uploaded
ianitor-0.1.0.tar.gz 7.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ianitor 0.1.0
File Interpreter ABI Platform
ianitor-0.1.0-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 17.1 kB

Release files / ianitor-0.1.0.tar.gz

Download URL ianitor-0.1.0.tar.gz
Size 7.8 kB
Tags Source
SHA-256 checksum
How to use checksums
379c4831387b8124ad4259197275635baf70ab32d395f1d88aea778d183ba484
BLAKE2b-256 checksum
How to use checksums
3e10012209b1e64f44e9fcd3fec93135ab7908f0920fa2b9145017038259433c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / ianitor-0.1.0-py2.py3-none-any.whl

Download URL ianitor-0.1.0-py2.py3-none-any.whl
Size 9.3 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
264eb38dcfa9b9172c311b314333f547229581b7b8fbbcc01ceaf0d3d1c73e85
BLAKE2b-256 checksum
How to use checksums
a880b89c946d8808448a3d81470b8218fbb214e8adeb4390d6b8e3b6797f1e8c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

0.0.5

2 release files

0.0.4

1 release file

0.0.3

1 release file

0.0.2

1 release file

0.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page