Пример #1
0
        # Create Gearman agents with using information from database
        for node in scoper.models.Gearman.objects.all():
            # Add gearman node object and related , which will
            # periodicaly call gearman-admin util via socket interface
            # in order to get informations about node status and queues
            s.add_agent(GearmanNodeAgent(server=ServerPool.get(node.server.name), port=node.port))

        # Create all pools disribed in setting.py module
        for name, pool in settings.SONAR_AGENT_POOLS.iteritems():
            # Against string value of full class name for prototype,
            # we should use class type from imported related module
            if pool['prototype'].find('.') != -1:
                parts = pool['prototype'].split('.')
                pool['prototype'] = reduce(lambda module,attr: getattr(module,attr),
                                            parts[1:], __import__(parts[0]))
            else:
                pool['prototype'] = globals()[pool['prototype']]

            # Create agent pool with given name, which will consist from
            # given count of object, builded on as instance of prototype class
            s.add_pool(name, AgentPool(**pool))

        return s
    return make

if __name__ == '__main__':
    Log.BUFFER_FILE = settings.SONAR_CONFIGURATION_FILE
    loop.main(factory=sonar_factory())

Пример #2
0
 def handle(self, *args, **options):
     Log.BUFFER_FILE = settings.SONAR_LOG_FILE
     loop.main(factory=sonar_factory())