class DevelopmentConfig(Config): DEBUG = True SCHEDULER_API_ENABLED = True SCHEDULER_AUTH = HTTPBasicAuth() @staticmethod def init_app(app): print("DevelopmentConfig init_app")
def setUp(self): self.app = Flask(__name__) self.scheduler = APScheduler() self.scheduler.auth = HTTPBasicAuth() self.scheduler.api_enabled = True self.scheduler.init_app(self.app) self.scheduler.start() self.scheduler.authenticate(self._authenticate) self.client = self.app.test_client()
class Config(object): JOBS = [{ 'id': 'job1', 'func': '__main__:job1', 'args': (1, 2), 'trigger': 'interval', 'seconds': 10 }] SCHEDULER_API_ENABLED = True SCHEDULER_AUTH = HTTPBasicAuth()
class Config(object): JOBS = [ { 'id': 'job1', 'func': 'index:test_task', 'args': (1, 2), 'trigger': 'interval', 'seconds': 3 } ] SCHEDULER_API_ENABLED = True SCHEDULER_AUTH = HTTPBasicAuth()
class Config(object): JOBS = [ { 'id': 'job1', 'func': '__main__:job1', 'args': (), 'trigger': 'cron', 'minute': '*/10' } ] SCHEDULER_API_ENABLED = True SCHEDULER_AUTH = HTTPBasicAuth()
class Config: """App configuration.""" JOBS = [ { "id": "job1", "func": "__main__:job1", "args": (1, 2), "trigger": "interval", "seconds": 10, } ] SCHEDULER_API_ENABLED = True SCHEDULER_AUTH = HTTPBasicAuth()
SCHEDULER_JOB_DEFAULTS = {'coalesce': True, 'misfire_grace_time': 3600} SCHEDULER_EXECUTORS = {'default': ContextThreadExecutor(2)} # Indicates whether to start the scheduler server. Should only be set if # the dashboard is being run through a webserver (i.e. not just imported) SCHEDULER_ENABLED = read_boolean("DASHBOARD_SCHEDULER") if SCHEDULER_ENABLED: # Controls whether to allow remote job submission (over HTTP) SCHEDULER_API_ENABLED = read_boolean("DASHBOARD_SCHEDULER_API") if SCHEDULER_API_ENABLED: # Password protect the API. This should never be used over the open # internet unless HTTPS is being used SCHEDULER_AUTH = HTTPBasicAuth() else: SCHEDULER_API_ENABLED = False # Username to use when submitting jobs. Credentials must match on server and # clients. SCHEDULER_USER = os.environ.get('DASHBOARD_SCHEDULER_USER') # Password to use when submitting jobs. Credentials must match on server and # clients. SCHEDULER_PASS = os.environ.get('DASHBOARD_SCHEDULER_PASS') # The server URL to send scheduled jobs to. (Client/imported instances only) SCHEDULER_SERVER_URL = os.environ.get("DASHBOARD_URL")
class Config(object): SCHEDULER_API_ENABLED = True SCHEDULER_AUTH = HTTPBasicAuth()
class SchedulerConfig(object): JOBS = [ { 'id': 'job1', 'func': 'application.config.scheduler:print_test', 'args': ('joke', ), 'trigger': 'interval', 'seconds': 1, # 'start_date': '2019-05-22 14:00:00', # 'end_date': '2019-05-22 16:00:00', # 'jitter': 10 } # { # 'id': 'date_trigger', # 'func': 'application.config.scheduler:print_test', # 'args': ('joke',), # 'trigger': 'date', # 'run_date': '2019-05-22 11:58:00' # } # { # 'id': 'date_trigger', # 'func': 'application.config.scheduler:print_test', # 'args': ('joke',), # 'trigger': 'date', # 'run_date': date(2019, 5, 22) # } # { # 'id': 'date_trigger', # 'func': 'application.config.scheduler:print_test', # 'args': ('joke',), # 'trigger': 'date', # 'run_date': datetime(2019, 5, 22, 12, 5, 0, 0) # } # { # 'id': 'cron_trigger', # 'func': 'application.config.scheduler:print_test', # 'args': ('joke',), # 'trigger': 'cron', # 'month': '6-8,11-12', # 'day': '3rd fri', # 'start_date': '2019-05-22 14:00:00', # 'end_date': '2019-05-22 16:00:00', # 'jitter': 10 # # } # { # 'id': 'cron_trigger', # 'func': 'application.config.scheduler:print_test', # 'args': ('joke',), # 'trigger': CronTrigger.from_crontab('* * * * *'), # 'executor': 'process', # } ] SCHEDULER_JOBSTORES = { 'default': MemoryJobStore(), # 'sqlalchemy': SQLAlchemyJobStore(url='sqlite:///test.db'), # 'redis': RedisJobStore(host='localhost', port=6379), # 'rethinkdb': RethinkDBJobStore(host='localhost', port=28015) # 'mongodb': MongoDBJobStore(host='localhost',port=27017) # 'zookeeper': ZooKeeperJobStore(hosts='localhost:2181') } SCHEDULER_EXECUTORS = { 'default': { 'type': 'threadpool', 'max_workers': 20 }, 'process': { 'type': 'processpool', 'max_workers': 10 } } # SCHEDULER_ALLOWED_HOSTS = ['localhost'] SCHEDULER_API_ENABLED = True SCHEDULER_AUTH = HTTPBasicAuth()
class SchedulerApiConfig: SCHEDULER_API_ENABLED = True SCHEDULER_ALLOWED_HOSTS = [sched.host_name] # 限制可调用的 hosts,默认无限制 SCHEDULER_API_PREFIX = '/scheduler' # 默认就是这个 SCHEDULER_AUTH = HTTPBasicAuth() # 可以自己配置