def event_logger(options, proc_num, pipe): p_upstream = int(os.read(pipe[0], 100)) log.info('event_logger daemon port: %s', p_upstream) setproctitle('zcmd:eventlog(w)') context = zmq.Context() s_upstream = context.socket(zmq.PULL) # s_upstream.setsockopt(zmq.HWM, HWM) s_upstream.connect('tcp://localhost:' + str(p_upstream)) # Start event logger journal_dir = '%s/%s' % (options.journal, proc_num) log.info('Journaling to %s', journal_dir) if not os.path.exists(journal_dir): os.makedirs(journal_dir) j = journal.JournalWriter(options, journal_dir) # Handle messages while True: msg = s_upstream.recv() obj = bson.BSON(msg).decode() command = obj.pop('$command', None) if command != 'event_noval': obj = model.event(obj).make(obj) j(obj)
def _handle_event(self, obj): """Validate event, save to journal (and mongo)""" ev = model.event(obj).make(obj) self._j(ev)