def main():
    filename = os.path.abspath(os.path.join(os.path.dirname(__file__), '..',
        'tmp')) + '\\' + 'spider.log'
logging.basicConfig(filename=filename, level=logging.DEBUG, format=
    '%(levelname)s[%(asctime)s]: %(message)s')
sched = Scheduler()
Make APScheduler run in background in web app