Esempio n. 1
0
    def on_start(self):
        super(WebServiceInterface, self).on_start()
        setup_logger("werkzeug")
        setup_logger("gevent")
        if self.uses_static_port:
            try:
                socket_fd = self.container.get_shared_socket_fd(self.http_port)
            except NoSharedSockets:
                pass
            except SocketNotCreated:
                logger.warning(
                    "socket for port %s wasn't created by node, binding from instance instead", self.http_port
                )
            else:
                self.http_socket = sockets.create_socket("fd://%s" % socket_fd)
        if not self.http_socket:
            address = "%s:%s" % (self.container.server.ip, self.http_port)
            self.http_socket = sockets.create_socket(address)
        self.wsgi_server = LymphWSGIServer(self.http_socket, self.application, spawn=Group(self.pool_size))
        self.wsgi_server.start()

        web_instance = ServiceInstance(
            id=self.id,
            identity=self.container.identity,
            hostname=socket.gethostname(),
            ip=self.container.server.ip,
            http_port=self.http_port,
        )
        self.container.service_registry.register(self.name, web_instance, namespace="http")
Esempio n. 2
0
    def on_start(self):
        super(WebServiceInterface, self).on_start()
        setup_logger('werkzeug')
        setup_logger('gevent')
        if self.uses_static_port:
            try:
                socket_fd = self.container.get_shared_socket_fd(self.http_port)
            except NoSharedSockets:
                pass
            except SocketNotCreated:
                logger.warning(
                    "socket for port %s wasn't created by node, binding from instance instead",
                    self.http_port)
            else:
                self.http_socket = sockets.create_socket('fd://%s' % socket_fd)
        if not self.http_socket:
            address = '%s:%s' % (self.container.server.ip, self.http_port)
            self.http_socket = sockets.create_socket(address)
        self.wsgi_server = LymphWSGIServer(self.http_socket,
                                           self.application,
                                           spawn=Group(self.pool_size))
        self.wsgi_server.start()

        web_instance = ServiceInstance(
            identity=self.container.identity,
            hostname=socket.gethostname(),
            ip=self.container.server.ip,
            http_port=self.http_port,
        )
        self.container.service_registry.register(self.name,
                                                 web_instance,
                                                 namespace='http')
Esempio n. 3
0
 def on_start(self, timeout=10):
     setup_logger('kazoo')
     self.start_count += 1
     if self.start_count > 1:
         return
     started = self.client.start_async()
     started.wait(timeout=timeout)
     if not self.client.connected:
         raise RuntimeError('could not connect to zookeeper')
     logger.debug('connected to zookeeper (version=%s)', '.'.join(map(str, self.client.server_version())))
Esempio n. 4
0
 def on_start(self, timeout=10):
     setup_logger('kazoo')
     self.start_count += 1
     if self.start_count > 1:
         return
     started = self.client.start_async()
     started.wait(timeout=timeout)
     if not self.client.connected:
         raise RuntimeError('could not connect to zookeeper')
     logger.debug('connected to zookeeper (version=%s)',
                  '.'.join(map(str, self.client.server_version())))
Esempio n. 5
0
 def on_start(self):
     super(WebServiceInterface, self).on_start()
     setup_logger('werkzeug')
     setup_logger('gevent')
     try:
         socket_fd = self.container.get_shared_socket_fd(self.http_port)
     except SocketNotCreated:
         logger.warning("socket for port %s wasn't created by node, binding from instance instead", self.http_port)
         address = '%s:%s' % (self.container.server.ip, self.http_port)
         self.http_socket = create_socket(address)
     else:
         self.http_socket = create_socket('fd://%s' % socket_fd)
     self.wsgi_server = LymphWSGIServer(self.http_socket, self.application, spawn=Group(self.pool_size))
     self.wsgi_server.start()
Esempio n. 6
0
 def on_start(self):
     super(WebServiceInterface, self).on_start()
     setup_logger('werkzeug')
     setup_logger('gevent')
     try:
         socket_fd = self.container.get_shared_socket_fd(self.http_port)
     except SocketNotCreated:
         logger.warning("socket for port %s wasn't created by node, binding from instance instead", self.http_port)
         address = '%s:%s' % (self.container.server.ip, self.http_port)
         self.http_socket = sockets.create_socket(address)
     else:
         self.http_socket = sockets.create_socket('fd://%s' % socket_fd)
     self.wsgi_server = LymphWSGIServer(self.http_socket, self.application, spawn=Group(self.pool_size))
     self.wsgi_server.start()
 def on_start(self):
     super(StoreInterface, self).on_start()
     logger = setup_logger("sqlalchemy.pool")
     if not self.container.debug:
         logger.setLevel(logging.ERROR)
Esempio n. 8
0
import functools
import json

import gevent
import lymph
from lymph.utils.logging import setup_logger
import tweepy

logger = setup_logger(__name__)


class Inbound(lymph.Interface):
    def apply_config(self, config):
        super(Inbound, self).apply_config(config)
        self.auth = self._create_auth(**config.root.get('twitter'))
        self.stream = self._create_stream(self.auth)
        self.api = tweepy.API(self.auth)
        self.track_terms = config.root.get('track_terms')

    def _create_auth(self, api_key, api_secret, access_token,
                     access_token_secret):
        auth = tweepy.OAuthHandler(api_key, api_secret)
        auth.set_access_token(access_token, access_token_secret)
        return auth

    def _create_stream(self, auth):
        listener = TweetStreamListener()
        listener.register_callback(self.tweet_received)
        return tweepy.Stream(auth, listener)

    def tweet_received(self, tweet):
Esempio n. 9
0
 def on_start(self):
     setup_logger('kombu')
     with self.get_connection() as conn:
         self.exchange(conn).declare()
         self.waiting_exchange(conn).declare()
         self.retry_exchange(conn).declare()
Esempio n. 10
0
 def on_start(self):
     setup_logger('kombu')
Esempio n. 11
0
 def on_start(self):
     setup_logger("kombu")
Esempio n. 12
0
File: kombu.py Progetto: torte/lymph
 def on_start(self):
     setup_logger('kombu')
Esempio n. 13
0
 def on_start(self):
     setup_logger('kombu')
     with self.get_connection() as conn:
         self.exchange(conn).declare()
         self.waiting_exchange(conn).declare()
         self.retry_exchange(conn).declare()