コード例 #1
0
ファイル: receiver.py プロジェクト: Alternhuman/deployer
def main(args=None):
    """
    Creates the servers, initializes the logging facility, publishes the ``MarcoPolo`` services and starts the ``io_loop``.
    """
    ip = getip(conf.INTERFACE)
    pid = os.getpid()

    #if not os.path.exists('/var/run/marcopolo'):
    #    makedirs('/var/run/marcopolo')
    logging.basicConfig(filename=conf.RECEIVER_LOG_FILE, level=getattr(logging, conf.RECEIVER_LOGLEVEL.upper()))


    httpServer = HTTPServer(app, ssl_options={
        "certfile": conf.RECEIVERCERT,
        "keyfile": conf.RECEIVERKEY,
        "cert_reqs": ssl.CERT_REQUIRED,
        "ca_certs": conf.APPCERT,
    })

    httpServer.listen(conf.RECEIVER_PORT)

    wsapp.listen(conf.RECEIVER_WEBSOCKET_PORT, 
            ssl_options={"certfile": conf.APPCERT,
                         "keyfile": conf.APPKEY})


    while True:
        try:
            Polo().publish_service(conf.RECEIVER_SERVICE_NAME, root=True)
            Polo().publish_service(conf.STATUS_MONITOR_SERVICE_NAME, root=True)
            break
        except PoloInternalException as e:
            logging.warning(e)
            time.sleep(1)
        except PoloException as i:
            logging.warning(i)
            break
    logging.info("Starting receiver on port %d. WebSockets on %d" % (conf.RECEIVER_PORT, conf.RECEIVER_WEBSOCKET_PORT))
    io_loop.start()
コード例 #2
0
ファイル: receiver.py プロジェクト: Alternhuman/deployer
from marcopolo.bindings.polo import Polo, PoloInternalException, PoloException

import six
from six.moves.urllib import parse as urlparse

from marcodeployer.bufferprocessor import ProcessReactor
from marcodeployer.statusmonitor import get_data
from marcodeployer.utils import getip 
from marcodeployer import conf

from marcodeployer import create_home
#ip = ""
ip = None
while ip == None:
    ip = getip(conf.INTERFACE)
    time.sleep(1)


opensockets={}
io_loop = ioloop.IOLoop.instance()
data_dict = {}
data_json = ""

response_dict = {}
statusmonitor_open_sockets =  []
getDataCallback = None
processes = {}

def shutdown():
    """