Add dockerfile

This commit is contained in:
dave 2017-10-30 17:08:31 -07:00
parent 3bf99e3624
commit 2a5639a28b
2 changed files with 17 additions and 14 deletions

15
Dockerfile Normal file
View File

@ -0,0 +1,15 @@
FROM ubuntu:artful
RUN apt-get update && \
apt-get install -y python3-setuptools python3-pip
ADD . /tmp/msgbus/
RUN pip3 install pyzmq==16.0.2 && \
cd /tmp/msgbus/ ; python3 setup.py install
USER nobody
EXPOSE 7000 7001
ENTRYPOINT ["mbusd"]

View File

@ -5,21 +5,9 @@ import zmq.asyncio
from contextlib import closing
from random import randint
import signal
from concurrent.futures import CancelledError
zmq.asyncio.install()
def exewrap(func):
async def wrapped(*args, **kwargs):
try:
await func(*args, **kwargs)
except:
print("EXCEPTIN")
import traceback
traceback.print_exc()
return wrapped
class MsgBusServerPeer(object):
__slots__ = ["alive", "server", "name", "pub_port", "sub_port", "bind", "protocol", "sub_sock", "sub_sock_addr",
@ -161,7 +149,6 @@ class MsgBusServer(object):
self.peer_monitor(),
self.stats_monitor()], loop=self.loop)
@exewrap
async def stats_monitor(self):
"""
Print out stats on an interval (messages/s etc)
@ -226,6 +213,7 @@ class MsgBusServer(object):
with closing(self.ctx.socket(zmq.SUB)) as peer_pub_socket:
peer_pub_socket.connect(peer_pub_addr)
peer_pub_socket.subscribe(b'__msgbus_meta')
async def wait_for_cmd(cmd_name, timeout=10):
start = time()
while time() - start < timeout:
@ -257,7 +245,7 @@ class MsgBusServer(object):
peer_response = await wait_for_cmd("__peer_response")
if peer_response:
# print("got peer resp: ", peer_response)
name, _ = peer_response.split(" ", 1)
name, _ = peer_response.split(" ", 1)
if name == self.name:
break
await asyncio.sleep(1)