Пример #1
0
    def run(self):
        try:
            from scheduler import setup_scheduler, scheduler
        except ImportError:
            from example1.scheduler import setup_scheduler, scheduler
        while not self.got_sigterm():
            logging.info("Starting")
            self.program = oi.Program('example1', config.ctl_url)
            self.program.logger = self.logger
            self.program.add_command('ping', lambda: 'pong')
            self.program.add_command('state', lambda: self.program.state)

            def restart():
                logging.warning('Restarting')
                self.program.continue_event.set()

            self.program.restart = restart
            setup_scheduler(self.program)
            if hasattr(config, 'register_hook'):
                config.register_hook(ctx=dict(
                    locals=locals(), globals=globals(), program=self.program))
            self.program.run()
            logging.warning("Stopping")
            scheduler.shutdown()
            if not self.program.continue_event.wait(0.1):
                break
            self.stop()
            os.unlink('/tmp/demo.pid')
            os.execl(sys.executable, sys.argv[0], 'start')
        if self.got_sigterm():
            self.program.stop_function()
Пример #2
0
def run():
    scheduler.start()
    try:
        asyncio.get_event_loop().run_forever()
    except (KeyboardInterrupt, SystemExit):
        print("Shutting down. Please wait...")
        scheduler.shutdown(wait=True)
        exit(0)
Пример #3
0
def main():
    program = oi.Program('example1', config.ctl_url)
    program.add_command('ping', lambda: 'pong')
    program.add_command('state', lambda: program.state)
    try:
        from scheduler import setup_scheduler, scheduler
    except ImportError:
        from example1.scheduler import setup_scheduler, scheduler
    setup_scheduler(program)
    if hasattr(config, 'register_hook'):
        config.register_hook(
            ctx=dict(locals=locals(), globals=globals(), program=program))
    program.run()
    scheduler.shutdown()
Пример #4
0
 def tearDown(self):
     scheduler.shutdown()
     with self.app.app_context():
         db.session.remove()
         db.drop_all()
Пример #5
0
def _run():
    try:
        scheduler.start()
        app.run(threaded=True, use_reloader=False, processes=1)
    except KeyboardInterrupt, SystemExit:
        scheduler.shutdown()
Пример #6
0
'''
Heroku scheduler will invoke this script every 10 minutes.
This is necessary to start cron jobs created at Tron CI.
'''
from scheduler import scheduler
import logging
import time


logging.basicConfig(
    level=logging.DEBUG,
    format='[%(asctime)s]: %(levelname)s : %(message)s'
)
logger = logging.getLogger(__name__)

logger.info('Reloading Tron CI scheduler')
scheduler.start()

# Giving enough time to restore and execute all jobs.
time.sleep(30)

# Shutdown scheduler after all jobs has finished.
scheduler.shutdown()
while scheduler.running:
    pass

logger.info('Reload process finished')
Пример #7
0
def _run():
    try:
        scheduler.start()
        app.run(threaded=True, use_reloader=False, processes=1)
    except KeyboardInterrupt, SystemExit:
        scheduler.shutdown()