Configure logging for ZMQ PubServer daemon

This commit is contained in:
Daniel A. Wozniak 2018-11-01 13:44:12 -07:00
parent b947a18500
commit 889983223d
No known key found for this signature in database
GPG key ID: 166B9D2C06C82D61
2 changed files with 8 additions and 3 deletions

View file

@ -529,8 +529,9 @@ class Master(SMaster):
self.process_manager = salt.utils.process.ProcessManager(wait_for_kill=5)
pub_channels = []
log.info('Creating master publisher process')
log_queue = salt.log.setup.get_multiprocessing_logging_queue()
for transport, opts in iter_transport_opts(self.opts):
chan = salt.transport.server.PubServerChannel.factory(opts)
chan = salt.transport.server.PubServerChannel.factory(opts, log_queue=log_queue)
chan.pre_fork(self.process_manager)
pub_channels.append(chan)
@ -589,7 +590,7 @@ class Master(SMaster):
log.info('Creating master request server process')
kwargs = {}
if salt.utils.is_windows():
kwargs['log_queue'] = salt.log.setup.get_multiprocessing_logging_queue()
kwargs['log_queue'] = log_queue
kwargs['secrets'] = SMaster.secrets
self.process_manager.add_process(

View file

@ -21,6 +21,7 @@ from salt.ext.six.moves import map
import salt.auth
import salt.crypt
import salt.utils
import salt.log.setup
import salt.utils.verify
import salt.utils.event
import salt.utils.files
@ -737,10 +738,11 @@ class ZeroMQPubServerChannel(salt.transport.server.PubServerChannel):
'''
Encapsulate synchronous operations for a publisher channel
'''
def __init__(self, opts):
def __init__(self, opts, log_queue=None):
self.opts = opts
self.serial = salt.payload.Serial(self.opts) # TODO: in init?
self.ckminions = salt.utils.minions.CkMinions(self.opts)
self.log_queue = log_queue
def connect(self):
return tornado.gen.sleep(5)
@ -750,6 +752,8 @@ class ZeroMQPubServerChannel(salt.transport.server.PubServerChannel):
Bind to the interface specified in the configuration file
'''
salt.utils.appendproctitle(self.__class__.__name__)
if self.log_queue:
salt.log.setup.set_multiprocessing_logging_queue(self.log_queue)
# Set up the context
context = zmq.Context(1)
# Prepare minion publish socket