https://github.com/ultrabug/uwsgi-consul-demo
POC on the usage of the consul plugin for uWSGI
https://github.com/ultrabug/uwsgi-consul-demo
Last synced: 2 months ago
JSON representation
POC on the usage of the consul plugin for uWSGI
- Host: GitHub
- URL: https://github.com/ultrabug/uwsgi-consul-demo
- Owner: ultrabug
- License: mit
- Created: 2014-08-08T16:58:06.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2014-08-14T08:54:57.000Z (over 10 years ago)
- Last Synced: 2024-12-27T00:40:28.957Z (4 months ago)
- Language: Python
- Size: 137 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
uWSGI Consul.io integration demo
================================This is a proof of concept on the usage of the **consul** plugin for **uWSGI**.
This illustrates how simple it can be to create a distributed application running through **uWSGI** which can scale up and down automatically by using **Consul.io** for service discovery.
Prerequisities
==============* A running `consul` agent : http://www.consul.io/intro/getting-started/install.html
* A `uWSGI` installation with the consul plugin available : https://github.com/unbit/uwsgi-consul
* The `consulate` python library (available via pip)Run the POC
===========## Client
Run a `client` which will query the consul agent for the `consul-demo-server` service and list them on the console:* Open a terminal and run the `client`
```sh
python client.py
```* At first, there should be no available service
```
no consul-demo-server available
```## Servers
uWSGI will spawn two `servers` pretending to be listening on port `2001` and port `2002` and register them on the configured consul agent (localhost by default):* Open a terminal and run `uwsgi` using the provided INI
```sh
uwsgi --ini uwsgi-consul-demo.ini --ini uwsgi-consul-demo.ini:server1 --ini uwsgi-consul-demo.ini:server2
```## Result
On the `client` terminal, you can see that it discovered the new services automatically. You can CTRL+C and restart the uwsgi servers on the other terminal and watch the show.
```
consul-demo-server found on node MYHOST (XX.XX.XX.XX) using port 2001
consul-demo-server found on node MYHOST (XX.XX.XX.XX) using port 2002
```Congratulations, you've experienced your first automated service discovery application !