Skip to content

honmaple/maple-scheduler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mape-scheduler

https://img.shields.io/badge/python-3.6-brightgreen.svg https://img.shields.io/badge/license-BSD-blue.svg

https://raw.githubusercontent.com/honmaple/maple-scheduler/master/example.png

Quickstart

from flask import Flask
from sche import sche, api

app = Flask(__name__)
app.config.from_object("config")
sche.init_app(app, start=True)
api.init_app(app)

if __name__ == '__main__':
    app.run()

Configure

example:

from apscheduler.jobstores.sqlalchemy import SQLAlchemyJobStore
from pytz import timezone

APSCHEDULER = {
    'jobstores': {
        'default': SQLAlchemyJobStore(url='sqlite:///test_scheduler.db')
    },
    'executors': {
        'default': {
            'type': 'threadpool',
            'max_workers': 20
        }
    },
    'job_defaults': {
        'coalesce': False,
        'max_instances': 3
    },
    'timezone': timezone('Asia/Shanghai'),
    'funcs': "jobs"
}
jobstoresapscheduler jobstores,default None
executorsapscheduler executors,default None
job_defaultsapscheduler job_defaults,default None
timezoneapscheduler timezone,default UTC
funcsstr or list, tasks where find,default []

Some Api

  • /scheduler
    • GET: get all jobs
    • POST: add a new job,the func is same as ‘jobs:vvv’
  • /scheduler/status
    • GET: get scheduler status,include running,executors,job_defaults
    • POST: start scheduler.You can pass parameter pause (default: False)
      # when pause in ['1',1,'true','True']
      pause = True 
              
    • DELETE: shutdown scheduler.You can pass parameter wait (default: True)
      # when wait in ['0',0,'False','false']
      wait = False 
              
  • /scheduler/<pk>
    • GET: get a job with id.
    • PUT: modify a job with id.
    • DELETE: delete a job with id.
  • /scheduler/<pk>/pause
    • POST: pause a job with id.
  • /scheduler/<pk>/resume
    • POST: resume a job with id.
  • /scheduler/<pk>/execute
    • POST: Executes a job with id right now.

Example

python runserver