Ods is a discovery/registry service that allows us to keep track of dynamic services added to our infrastructure and their status through regular health checks. e.g.: dynamic proxy servers.
- Python3.7+
- PIP3
To install, we basically run pip along with requirements.txt:
$ pip install -r requirements.txt
Configure a .env file with the following data:
[postgres]
database=discovery
host=<DATABASE_HOSTNAME>
username=<USERNAME>
password=<PASSWORD>
[load_balancer]
lb_address=<LOAD_BALANCER_ADDRESS>
In order to run the service, just type:
$ python3 main.py
By default, we run a health check task every 30 seconds and update the service status accordingly.
A newly registered service starts as unknown
. After the first successful health check, it's then updated to running
, otherwise it's updated to pending
. After 2 failures, the status is updated to failing
and after the third failure, the status is updated to disabled
.
Every 15 minutes we run a cleanup tasks that removes all services marked as disabled.
GET /services Get a list of all services with meta information (last_health_check, status, registered_at...).
POST /services Add a new service. e.g.: {"service_id": "<ID>", "host": "<IP_ADDRESS>", "port": 8888}
DELETE /services/<service_id>/<host>/<port> Delete a service.
- Document routes;
- Avoid duplicated services + hosts + ports;
- Dockerize;
- Use GUnicorn;
- Create a discovery.conf file;
- Log to /var/log/ods.log.