Files
dotfiles/.config/rofi/scripts/services
2020-02-17 18:57:34 +01:00

29 lines
575 B
Python
Executable File

#!/usr/bin/env python3
import re
import consul
import docker
import sys
import subprocess
running = {}
c = consul.Consul()
client = docker.from_env()
for services in c.catalog.services():
for service in services:
idx, details = c.catalog.service(service)
if len(details) == 0:
continue
for item in details:
link = item['ServiceName']+".service."+item['Datacenter']+".consul:"+str(item['ServicePort'])
print("http://"+link)
if sys.argv[1]:
subprocess.Popen(['xdg-open', sys.argv[1]])
sys.exit(1)