commit:     584e5b5dd357706b1d1614ccc393ba367def5eaa
Author:     Magnus Granberg <zorry <AT> gentoo <DOT> org>
AuthorDate: Wed Dec 30 08:20:41 2020 +0000
Commit:     Magnus Granberg <zorry <AT> gentoo <DOT> org>
CommitDate: Wed Dec 30 08:21:24 2020 +0000
URL:        
https://gitweb.gentoo.org/proj/tinderbox-cluster.git/commit/?id=584e5b5d

Add GentooCiService

Signed-off-by: Magnus Granberg <zorry <AT> gentoo.org>

 buildbot_gentoo_ci/config/service.py | 43 ++++++++++++++++++++++++++++++++++++
 master.cfg                           |  6 +++--
 2 files changed, 47 insertions(+), 2 deletions(-)

diff --git a/buildbot_gentoo_ci/config/service.py 
b/buildbot_gentoo_ci/config/service.py
new file mode 100644
index 0000000..af283b5
--- /dev/null
+++ b/buildbot_gentoo_ci/config/service.py
@@ -0,0 +1,43 @@
+# Copyright 2020 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+from twisted.python import log
+from twisted.internet import reactor, defer
+
+from buildbot import config as master_config
+from buildbot.db import exceptions
+from buildbot.scripts.base import isBuildmasterDir
+from buildbot.util.service import BuildbotService
+from buildbot import version
+
+from buildbot_gentoo_ci.db import connector as dbconnector
+from buildbot_gentoo_ci.config import config
+
+class GentooCiService(BuildbotService):
+
+    name="gentooci"
+
+    def checkConfig(self, basedir, **kwargs):
+        self.basedir = basedir
+        if not isBuildmasterDir(self.basedir):
+            master_config.error("Can't find buildbot.tac in basedir")
+            return
+
+    @defer.inlineCallbacks
+    def reconfigService(self, **kwargs):
+        return defer.succeed(None)
+
+    @defer.inlineCallbacks
+    def startService(self):
+        self.config_loader = config.FileLoader(self.basedir, 'gentooci.cfg')
+        self.config = self.config_loader.loadConfig()
+        self.db = dbconnector.DBConnector(self.basedir)
+        yield self.db.setServiceParent(self)
+        log.msg("Starting Gentoo-Ci Service -- buildbot.version: 
{}".format(version))
+        # setup the db
+        try:
+            yield self.db.setup(self.config)
+        except exceptions.DatabaseNotReadyError:
+            # (message was already logged)
+            reactor.stop()
+            return

diff --git a/master.cfg b/master.cfg
index 996f917..464d54d 100644
--- a/master.cfg
+++ b/master.cfg
@@ -1,6 +1,6 @@
 # -*- python -*-
 # ex: set filetype=python:
-from buildbot_gentoo_ci.config import schedulers, workers, builders
+from buildbot_gentoo_ci.config import schedulers, workers, builders, service
 
 # This is a sample buildmaster config file. It must be installed as
 # 'master.cfg' in your buildmaster's base directory.
@@ -51,7 +51,9 @@ c['builders'] = builders.gentoo_builders()
 # status of each build will be pushed to these targets. buildbot/reporters/*.py
 # has a variety to choose from, like IRC bots.
 
-#c['services'] = []
+c['services'] = [
+    service.GentooCiService(basedir)
+]
 
 ####### PROJECT IDENTITY
 

Reply via email to