forked from oss-compass/compass-metrics-model
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_scheduler_task.py
29 lines (19 loc) · 892 Bytes
/
run_scheduler_task.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
from apscheduler.schedulers.blocking import BlockingScheduler
from apscheduler.triggers.cron import CronTrigger
from compass_contributor.contributor_org import ContributorOrgService
import yaml
import logging
logger = logging.getLogger(__name__)
def cncf_gitdm_contributor_org_task():
contributor = ContributorOrgService(elastic_url, params['contributors_org_index'], "github")
contributor.save_by_cncf_gitdm_url()
if __name__ == '__main__':
config_url = './conf-github.yaml'
CONF = yaml.safe_load(open(config_url))
elastic_url = CONF['url']
params = CONF['params']
scheduler = BlockingScheduler()
trigger = CronTrigger(day='1', hour='0', minute='0') #Triggered once a month on the 1st
scheduler.add_job(cncf_gitdm_contributor_org_task, trigger, id="cncf_gitdm_contributor_org_task")
logger.info("scheduler start")
scheduler.start()