Moved Docker stuff to "Docker" folder

Created k8s folder for k8s stuff
Added early-stage service.yaml for K8s deployment
This commit is contained in:
erichardso
2018-08-28 11:51:23 -07:00
parent 176e2f2062
commit d880f44ca6
138 changed files with 11 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
#===========================================================================
#
# msgHub package
#
#===========================================================================
__doc__ = """Zero-MQ Message Hub
The msgHub is a pub/sub forwarder. All of the various data producers
send messages to the msgHub as a single point of contact for the
producers. Consumers of the messages read from the hub as a single
point of contact for the consumers.
Logging object name: tHome.msgHub
"""
#===========================================================================
#===========================================================================
from . import cmdLine
from . import config
from .start import start
#===========================================================================

View File

@@ -0,0 +1,53 @@
#===========================================================================
#
# Command line parsing.
#
#===========================================================================
__doc__ = """Command line parsing.
"""
import argparse
from .. import config as C
from .. import util
from . import config
from . import start
#===========================================================================
def run( args ):
"""Parse command line arguments to start the hub.
This will parse the inputs and start the hub (it never returns).
= INPUTS
- args [str]: List of command line arguments. [0] should be the
program name.
"""
p = argparse.ArgumentParser( prog=args[0], description="T-Home message hub" )
p.add_argument( "-c", "--configDir", metavar="configDir",
default="/var/config/tHome",
help="Message hub configuration directory." )
p.add_argument( "-l", "--log", metavar="logFile",
default=None, help="Logging file to use. Input 'stdout' "
"to log to the screen." )
c = p.parse_args( args[1:] )
# Parse all the config files and extract the MsgHub data.
data = C.parse( c.configDir )
cfg = config.update( data )
# Override the log file.
if c.log:
cfg.LogFile = C.toPath( c.log )
if cfg.LogFile:
log = util.log.get( "msgHub" )
log.writeTo( cfg.LogFile )
log.setLevel( cfg.LogLevel )
start.start( cfg.InputPort, cfg.OutputPort )
#===========================================================================

View File

@@ -0,0 +1,34 @@
#===========================================================================
#
# Config file
#
#===========================================================================
__doc__ = """Config file parsing.
"""
from .. import config as C
#===========================================================================
# Config file section name and defaults.
sectionDef = {
"MsgHub" : [
# ( name, converter function, default value )
( "Host", str, None ),
( "InputPort", int, 22040 ),
( "OutputPort", int, 22041 ),
( "LogFile", C.toPath, None ),
( "LogLevel", int, 20 ), # INFO
],
}
#===========================================================================
def update( data ):
C.update( data, sectionDef )
return data.MsgHub
#===========================================================================

View File

@@ -0,0 +1,75 @@
#===========================================================================
#
# Main MsgHub class.
#
#===========================================================================
__doc__ = """Zero-MQ Message Hub
The msgHub is a pub/sub forwarder. All of the various data producers
send messages to the msgHub as a single point of contact for the
producers. Consumers of the messages read from the hub as a single
point of contact for the consumers.
Original code from:
http://learning-0mq-with-pyzmq.readthedocs.org/en/latest/pyzmq/devices/forwarder.html
"""
import zmq
from .. import util
#===========================================================================
def start( inPort, outPort ):
"""Start forwarding messages.
This function never returns.
= INPUTS
- inPort int: Input XSUB subscriber port number to use.
- outPort int: Output XPUB publisher port number to use.
"""
log = tHome.util.log.get( "msgHub" )
ctx = zmq.Context()
intSock, outSock = None, None
try:
# Inbound message port.
log.info( "Starting inbound subscribe socket at port %d" % inPort )
inSock = ctx.socket( zmq.XSUB )
# Use * to bind on all interfaces. Otherwise the address has to
# be an exact match (127.0.0.1 != IP).
inSock.bind( "tcp://*:%d" % inPort )
# Outbound message port.
log.info( "Starting outbound publish socket at port %d" % outPort )
outSock = ctx.socket( zmq.XPUB )
outSock.bind( "tcp://*:%d" % outPort )
# Use ZMP to handle all the forwarding. We could add logging
# here but it's easier just to add a new subscriber to read and
# log any messages.
#
# NOTE: this never returns.
log.info( "Starting forwarding" )
zmq.device( zmq.FORWARDER, inSock, outSock )
except ( Exception, KeyboardInterrupt ) as e:
log.critical( "Exception thrown", exc_info=True )
raise
finally:
if inSock:
inSock.close()
if outSock:
outSock.close()
ctx.term()
#===========================================================================