mirror of
https://github.com/IEEE-SB-Passau/pelican-deployment-system.git
synced 2017-09-06 16:35:38 +02:00
things
This commit is contained in:
@@ -3,30 +3,38 @@
|
|||||||
from pelican_deploy import DeploymentRunner
|
from pelican_deploy import DeploymentRunner
|
||||||
from apscheduler.schedulers.background import BackgroundScheduler
|
from apscheduler.schedulers.background import BackgroundScheduler
|
||||||
from importlib.machinery import SourceFileLoader
|
from importlib.machinery import SourceFileLoader
|
||||||
|
from operator import methodcaller
|
||||||
|
from bottle import run, default_app
|
||||||
import pelican_deploy.webhookbottle
|
import pelican_deploy.webhookbottle
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
#for r in runners.values():
|
|
||||||
# r.build_blocking()
|
|
||||||
|
|
||||||
config = SourceFileLoader("config", "deploy_config.py").load_module()
|
config = SourceFileLoader("config", "deploy_config.py").load_module()
|
||||||
|
|
||||||
runners = {name: DeploymentRunner(name, conf)
|
runners = {name: DeploymentRunner(name, conf)
|
||||||
for name, conf in config.RUNNERS.items()}
|
for name, conf in config.RUNNERS.items()}
|
||||||
|
|
||||||
# start a scheduler
|
#for r in runners.values():
|
||||||
scheduler = BackgroundScheduler()
|
# print(r.build(wait=True))
|
||||||
scheduler.start()
|
|
||||||
|
schedulers = {r: BackgroundScheduler(daemon=False) for r in runners}
|
||||||
|
for s in schedulers.values():
|
||||||
|
s.start()
|
||||||
|
|
||||||
for i, (rname, trigger) in enumerate(config.SCHEDULED_BUILD_JOBS):
|
for i, (rname, trigger) in enumerate(config.SCHEDULED_BUILD_JOBS):
|
||||||
scheduler.add_job(runners[rname].build, trigger=trigger,
|
schedulers[rname].add_job(runners[rname].build, trigger=trigger,
|
||||||
name="{} ({})".format(i, rname))
|
name="{} ({})".format(rname, i),
|
||||||
|
id="{}_{}".format(rname, i), max_instances=1,
|
||||||
|
kwars={"wait" : True})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
pelican_deploy.webhookbottle.set_runners(**runners)
|
pelican_deploy.webhookbottle.set_runners(**runners)
|
||||||
pelican_deploy.webhookbottle.set_github_secret(config.GITHUB_SECRET)
|
pelican_deploy.webhookbottle.set_github_secret(config.GITHUB_SECRET)
|
||||||
pelican_deploy.webhookbottle.devrun()
|
default_app().mount("/hooks/", pelican_deploy.webhookbottle.app)
|
||||||
|
|
||||||
|
run(host='0.0.0.0', port=4000, debug=True)
|
||||||
|
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ class DeploymentRunner:
|
|||||||
|
|
||||||
# deinit submodules to avoid removed ones dangling around later
|
# deinit submodules to avoid removed ones dangling around later
|
||||||
# they should stay around in .git, so reinit should be fast
|
# they should stay around in .git, so reinit should be fast
|
||||||
result = repo.submodule("deinit", ".")
|
result = repo.submodule("deinit", "--force", ".")
|
||||||
log_git(result)
|
log_git(result)
|
||||||
|
|
||||||
result = repo.checkout("--force", self.git_branch)
|
result = repo.checkout("--force", self.git_branch)
|
||||||
@@ -111,7 +111,7 @@ class DeploymentRunner:
|
|||||||
result = repo.submodule("update", "--init", "--force", "--recursive")
|
result = repo.submodule("update", "--init", "--force", "--recursive")
|
||||||
log_git(result)
|
log_git(result)
|
||||||
|
|
||||||
def build(self, abort_running=False):
|
def build(self, abort_running=False, wait=False):
|
||||||
with self._build_lock:
|
with self._build_lock:
|
||||||
if abort_running:
|
if abort_running:
|
||||||
self.try_abort_build()
|
self.try_abort_build()
|
||||||
@@ -123,7 +123,10 @@ class DeploymentRunner:
|
|||||||
self._futures.remove(fut)
|
self._futures.remove(fut)
|
||||||
|
|
||||||
build_func = exception_logged(self.build_blocking, log.error)
|
build_func = exception_logged(self.build_blocking, log.error)
|
||||||
self._futures.add(self._executor.submit(build_func))
|
future = self._executor.submit(build_func)
|
||||||
|
self._futures.add(future)
|
||||||
|
if wait:
|
||||||
|
return future.result()
|
||||||
|
|
||||||
def try_abort_build(self):
|
def try_abort_build(self):
|
||||||
proc = self._build_proc
|
proc = self._build_proc
|
||||||
|
|||||||
@@ -62,5 +62,3 @@ def github(name):
|
|||||||
_start_build(name, hook.get("ref", ""))
|
_start_build(name, hook.get("ref", ""))
|
||||||
return "Success!"
|
return "Success!"
|
||||||
|
|
||||||
def devrun():
|
|
||||||
run(app=app, host='0.0.0.0', port=4000, debug=True)
|
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
bottle
|
bottle
|
||||||
apscheduler
|
apscheduler
|
||||||
|
pytz
|
||||||
|
tzlocal
|
||||||
tox
|
tox
|
||||||
|
|||||||
Reference in New Issue
Block a user