def __init__(self, jobstore, url): self.logger = setup(__name__) self.logger.debug("Creating MessageScheduler") self.logger.debug("id = {}".format(id(self))) config = read_env('config.cfg') self._scheduler = Scheduler(daemonic=True) config_scheduler = {'apscheduler.jobstores.file.class': 'apscheduler.jobstores%s' % jobstore, 'apscheduler.jobstores.file.url': url} self._scheduler.configure(config_scheduler) #Open a publishing socket to the forwarder to pass messages out self.broadcast_socket = zmq.Context().socket(zmq.PUB) self.broadcast_socket.connect(config['ZMQ_FORWARDER_SUCKS_IN'])
def __init__(self, jobstore, url): self.socket = zmq.Context().socket(zmq.SUB) self.logger = setup(__name__) self.logger.debug("Creating MessageScheduler") self.logger.debug("id = {}".format(id(self))) config = read_env('config.cfg') self._scheduler = Scheduler(daemonic=True) config_scheduler = {'apscheduler.jobstores.file.class': 'apscheduler.jobstores%s' % jobstore, 'apscheduler.jobstores.file.url': url} self._scheduler.configure(config_scheduler) # Open a publishing socket to the forwarder to pass messages out self.broadcast_socket = zmq.Context().socket(zmq.PUB) self.broadcast_socket.connect(config['ZMQ_FORWARDER_SUCKS_IN'])
import zmq from env import read_env from logme import setup logger = setup(__name__) def main(): try: import os dr = os.path.dirname(os.path.realpath(__file__)) config = read_env('{}/config.cfg'.format(dr)) except: config = read_env('config.cfg') logger.info("Launching forwarder sucking and spitting") #Create the sucking socket try: context = zmq.Context(1) # Socket facing clients frontend = context.socket(zmq.SUB) frontend.bind(config['ZMQ_FORWARDER_SUCKS_IN']) frontend.setsockopt(zmq.SUBSCRIBE, "") #subscribe to everything except Exception, e: logger.debug(str(e)) logger.debug("Bringing down sucking device") #Create the spitting socket, create the forwarder try: # Socket facing services backend = context.socket(zmq.PUB) backend.bind(config['ZMQ_FORWARDER_SPITS_OUT'])
import atexit import argparse from env import read_env from scheduler import MessageScheduler from multiprocessing import Process from logme import setup logger = setup(__name__) def run(): config = read_env('config.cfg') scheduler = MessageScheduler(config['jobstore'], config['url']) # start APscheduler daemon in own thread scheduler.start_ap_daemon() # shut scheduler threads cleanly at exit atexit.register(lambda: scheduler.shutdown()) logger.info("About to launch scheduler listener") # start listener for new schedule events from anywhere try: scheduler.start_listener() except KeyboardInterrupt: scheduler.shutdown() except Exception, e: logger.debug("exception in scheculer start_listener():{}".format(e))
def start_ap_daemon(self): self.logger.info("scheduler start") setup("apscheduler.scheduler") self._scheduler.start()