Exemplo n.º 1
0
class Server(threading.Thread):
    def __init__(self,
                 parent: object = None,
                 ip: str = '0.0.0.0',
                 port: str = '0'):
        threading.Thread.__init__(self)
        try:
            self.parent = parent
            protocol = 'tcp'
            if self.parent.type.lower(
            ) == 'management' or self.parent.type.lower() == 'schedule':
                protocol = 'http'
            self.url = str("%s://%s:%s" % (protocol, ip, port))

            self.service = None
            if self.parent.type.lower() == 'management':
                wsgi_application = WsgiApplication(Management)
                self.server = make_server(ip, int(port), wsgi_application)
                self.service = self.server.application.app.services[0]
                self.service.handler = parent
            elif self.parent.type.lower() == 'schedule':
                wsgi_application = WsgiApplication(Schedule)
                self.server = make_server(ip, int(port), wsgi_application)
                self.service = self.server.application.app.services[0]
                self.service.handler = parent
            else:
                self.server = ZeroMQServer(Common, self.url)
                self.service = self.server.app.services[0]
                self.service.handler = parent
        except Exception as ex:
            logger.error("RPC Server Exception : %s", str(ex))
            self.parent.parent.writeLog(
                self,
                str("---- %s Handler RPC Server (%s) Exception ----" %
                    (self.parent.type, self.url)))
            pass

    def run(self):
        try:
            self.parent.parent.writeLog(
                self,
                str("---- %s Handler RPC Server Running (%s) ----" %
                    (self.parent.type, self.url)))
            self.server.serve_forever()
        except Exception as ex:
            logger.error("RPC Server Exception : %s", str(ex))
            self.parent.parent.writeLog(
                self,
                str("---- %s Handler RPC Server (%s) Exception ----" %
                    (self.parent.type, self.url)))
            pass
Exemplo n.º 2
0
def main():
    url = "tcp://%s:%d" % (host,port)

    logging.basicConfig(level=logging.DEBUG)
    logging.getLogger('spyne.protocol.xml').setLevel(logging.DEBUG)

    server = ZeroMQServer(soap_application, url)
    logging.info("************************")
    logging.info("Use Ctrl+\\ to exit if Ctrl-C does not work.")
    logging.info("See the 'I can't Ctrl-C my Python/Ruby application. Help!' "
                 "question in http://www.zeromq.org/area:faq for more info.")
    logging.info("listening on %r" % url)
    logging.info("************************")

    server.serve_forever()
Exemplo n.º 3
0
def main():
    url = "tcp://%s:%d" % (host, port)

    logging.basicConfig(level=logging.DEBUG)
    logging.getLogger('spyne.protocol.xml').setLevel(logging.DEBUG)

    server = ZeroMQServer(soap11_application, url)
    logging.info("************************")
    logging.info("Use Ctrl+\\ to exit if Ctrl-C does not work.")
    logging.info("See the 'I can't Ctrl-C my Python/Ruby application. Help!' "
                 "question in http://www.zeromq.org/area:faq for more info.")
    logging.info("listening on %r" % url)
    logging.info("************************")

    server.serve_forever()
Exemplo n.º 4
0
import logging

from app import app
from spyne.server.zeromq import ZeroMQServer

URL = "tcp://127.0.0.1:5001"
logging.info("Listening to %r", URL)

s = ZeroMQServer(app, URL)
s.serve_forever()
Exemplo n.º 5
0
#       this list of conditions and the following disclaimer.
#    2. Redistributions in binary form must reproduce the above copyright
#       notice, this list of conditions and the following disclaimer in the
#       documentation and/or other materials provided with the distribution.
#    3. Neither the name of the owner nor the names of its contributors may be
#       used to endorse or promote products derived from this software without
#       specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY DIRECT,
# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#

import logging

from app import app
from spyne.server.zeromq import ZeroMQServer

URL = "tcp://127.0.0.1:5001"
logging.info("Listening to %r", URL)

s = ZeroMQServer(app, URL)
s.serve_forever()