コード例 #1
0
ファイル: example1svc.py プロジェクト: janjaapbos/nanotest
    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
ファイル: __init__.py プロジェクト: cooper-software/flaneur
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
ファイル: __init__.py プロジェクト: cooper-software/flaneur
def _run():
    try:
        scheduler.start()
        app.run(threaded=True, use_reloader=False, processes=1)
    except KeyboardInterrupt, SystemExit:
        scheduler.shutdown()