mirror of
https://github.com/IEEE-SB-Passau/pelican-deployment-system.git
synced 2017-09-06 16:35:38 +02:00
add scheduler things
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import os
|
||||
import logging
|
||||
from apscheduler.triggers.cron import CronTrigger
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit("Not meant to be run directly!")
|
||||
@@ -49,4 +50,12 @@ RUNNERS = {
|
||||
}
|
||||
}
|
||||
|
||||
# define crojobs as sequence of (runner, trigger) pairs, for cron triggers see
|
||||
# http://apscheduler.readthedocs.io/en/latest/modules/triggers/cron.html
|
||||
SCHEDULED_BUILD_JOBS = [
|
||||
("website_master", CronTrigger(minute="*/5"))
|
||||
|
||||
]
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,18 +1,32 @@
|
||||
#! /usr/bin/env python3
|
||||
|
||||
import deploy_config
|
||||
from pelican_deploy import DeploymentRunner
|
||||
from apscheduler.schedulers.background import BackgroundScheduler
|
||||
from importlib.machinery import SourceFileLoader
|
||||
import pelican_deploy.webhookbottle
|
||||
import logging
|
||||
|
||||
|
||||
runners = {name: DeploymentRunner(name, conf)
|
||||
for name, conf in deploy_config.RUNNERS.items()}
|
||||
|
||||
if __name__ == "__main__":
|
||||
#for r in runners.values():
|
||||
# r.build_blocking()
|
||||
|
||||
config = SourceFileLoader("config", "deploy_config.py").load_module()
|
||||
|
||||
runners = {name: DeploymentRunner(name, conf)
|
||||
for name, conf in config.RUNNERS.items()}
|
||||
|
||||
# start a scheduler
|
||||
scheduler = BackgroundScheduler()
|
||||
scheduler.start()
|
||||
|
||||
for i, (rname, trigger) in enumerate(config.SCHEDULED_BUILD_JOBS):
|
||||
scheduler.add_job(runners[rname].build, trigger=trigger,
|
||||
name="{} ({})".format(i, rname))
|
||||
|
||||
|
||||
pelican_deploy.webhookbottle.set_runners(**runners)
|
||||
pelican_deploy.webhookbottle.set_github_secret(deploy_config.GITHUB_SECRET)
|
||||
pelican_deploy.webhookbottle.set_github_secret(config.GITHUB_SECRET)
|
||||
pelican_deploy.webhookbottle.devrun()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user