Merge pull request #13 from Surkoveds/consul

Consul
This commit is contained in:
Denis 2017-01-23 15:53:47 +02:00 committed by GitHub
commit d83ed8b752
5 changed files with 31 additions and 18 deletions

View File

@ -15,5 +15,6 @@ before_install:
- ./build.sh centos_rpm - ./build.sh centos_rpm
- ./build.sh fedora_rpm - ./build.sh fedora_rpm
# tests script
script: script:
- ./runtests.sh - ./runtests.sh

View File

@ -1,5 +1,5 @@
# Surok # Surok
[![Build Status](https://travis-ci.org/Difrex/surok.svg?branch=master)](https://travis-ci.org/Difrex/surok) [![Build Status](https://travis-ci.org/Surkoveds/surok.svg?branch=master)](https://travis-ci.org/Surkoveds/surok)
Service discovery for Apache Mesos. Service discovery for Apache Mesos.
@ -38,7 +38,7 @@ ENTRYPOINT is: ```cd /opt/surok && pytho3 surok.py -c /etc/surok/conf/surok.json
## Documentation ## Documentation
[Wiki](https://github.com/Difrex/surok/wiki) [Wiki](https://github.com/Surkoveds/surok/wiki)
## Known issues ## Known issues

View File

@ -1,22 +1,26 @@
{ {
"marathon": { "marathon": {
"force": true, "force": true,
"host": "http://marathon.mesos:8080", "host": "http://marathon.mesos:8080",
"enabled": false "enabled": false
}, },
"consul": {
"enabled": false,
"domain": "service.dc1.consul"
},
"confd": "/etc/surok/conf.d", "confd": "/etc/surok/conf.d",
"domain": "marathon.mesos", "domain": "marathon.mesos",
"wait_time": 20, "wait_time": 20,
"lock_dir": "/var/tmp", "lock_dir": "/var/tmp",
"loglevel": "info", "loglevel": "info",
"container": false, "container": false,
"memcached": { "memcached": {
"enabled": false, "enabled": false,
"discovery": { "discovery": {
"enabled": false, "enabled": false,
"service": "memcached", "service": "memcached",
"group": "system" "group": "system"
}, },
"hosts": ["localhost:11211"] "hosts": ["localhost:11211"]
} }
} }

3
debian/docs vendored
View File

@ -1,3 +1,4 @@
README.md README.md
doc/ru/* docs/*md
LICENSE
AUTHORS AUTHORS

View File

@ -12,7 +12,7 @@ def resolve(app, conf):
services = app['services'] services = app['services']
domain = conf['domain'] domain = conf['domain']
for service in services: for service in services:
hosts[service['name']] = [] hosts[service['name']] = []
group = get_group(service, app) group = get_group(service, app)
@ -45,6 +45,13 @@ def resolve(app, conf):
# } # }
# ] # ]
fqdn = '' fqdn = ''
# Discovery over Consul DNS
if 'consul' in conf and conf['consul']['enabled']:
fqdn = '_' + service['name'] + '._tcp.' + conf['consul']['domain']
hosts[service['name']].append(do_query(fqdn, conf['loglevel']))
continue
if ports is not None: if ports is not None:
for port_name in ports: for port_name in ports:
fqdn = '_' + port_name + '.' + '_' + service['name'] + '.' + group + '._tcp.' + domain # Need support for udp ports. See #16 fqdn = '_' + port_name + '.' + '_' + service['name'] + '.' + group + '._tcp.' + domain # Need support for udp ports. See #16