def init_sender(config):
gevent.signal(signal.SIGINT, sender_shutdown)
gevent.signal(signal.SIGTERM, sender_shutdown)
gevent.signal(signal.SIGQUIT, sender_shutdown)
process_title = config['sender'].get('process_title')
if process_title and isinstance(process_title, basestring):
setproctitle.setproctitle(process_title)
logger.info('Changing process name to %s', process_title)
api_host = config['sender'].get('api_host', 'http://localhost:16649')
db.init(config)
cache.init(api_host, config)
metrics.init(config, 'iris-sender', default_sender_metrics)
api_cache.cache_priorities()
api_cache.cache_applications()
api_cache.cache_modes()
global should_mock_gwatch_renewer, send_message
if config['sender'].get('debug'):
logger.info('DEBUG MODE')
should_mock_gwatch_renewer = True
should_skip_send = True
else:
should_skip_send = False
should_mock_gwatch_renewer = should_mock_gwatch_renewer or config.get('skipgmailwatch', False)
should_skip_send = should_skip_send or config.get('skipsend', False)
if should_skip_send:
config['vendors'] = [{
'type': 'iris_dummy',
'name': 'iris dummy vendor'
}]
global quota
quota = ApplicationQuota(db, cache.targets_for_role, message_send_enqueue, config['sender'].get('sender_app'))
global coordinator
zk_hosts = config['sender'].get('zookeeper_cluster', False)
if zk_hosts:
logger.info('Initializing coordinator with ZK: %s', zk_hosts)
from iris.coordinator.kazoo import Coordinator
coordinator = Coordinator(zk_hosts=zk_hosts,
hostname=socket.gethostname(),
port=config['sender'].get('port', 2321),
join_cluster=True)
else:
logger.info('ZK cluster info not specified. Using master status from config')
from iris.coordinator.noncluster import Coordinator
coordinator = Coordinator(is_master=config['sender'].get('is_master', True),
slaves=config['sender'].get('slaves', []))
评论列表
文章目录