diff mbox

[Branch,~linaro-validation/lava-scheduler/trunk] Rev 15: convert to a twistd plugin

Message ID 20110707095913.31225.38206.launchpad@loganberry.canonical.com
State Accepted
Headers show

Commit Message

Michael-Doyle Hudson July 7, 2011, 9:59 a.m. UTC
------------------------------------------------------------
revno: 15
committer: Michael-Doyle Hudson <michael.hudson@linaro.org>
branch nick: trunk
timestamp: Thu 2011-07-07 16:09:01 +1200
message:
  convert to a twistd plugin
added:
  twisted/
  twisted/plugins/
renamed:
  lava-scheduler-daemon.tac => twisted/plugins/twisted_lava_scheduler_daemon.py
modified:
  .bzrignore
  twisted/plugins/twisted_lava_scheduler_daemon.py


--
lp:lava-scheduler
https://code.launchpad.net/~linaro-validation/lava-scheduler/trunk

You are subscribed to branch lp:lava-scheduler.
To unsubscribe from this branch go to https://code.launchpad.net/~linaro-validation/lava-scheduler/trunk/+edit-subscription
diff mbox

Patch

=== modified file '.bzrignore'
--- .bzrignore	2011-06-21 00:58:19 +0000
+++ .bzrignore	2011-07-07 04:09:01 +0000
@@ -1,3 +1,4 @@ 
 *.egg-info
 ./twistd.pid
 ./_trial_temp
+./twisted/plugins/dropin.cache

=== added directory 'twisted'
=== added directory 'twisted/plugins'
=== renamed file 'lava-scheduler-daemon.tac' => 'twisted/plugins/twisted_lava_scheduler_daemon.py'
--- lava-scheduler-daemon.tac	2011-06-21 03:29:46 +0000
+++ twisted/plugins/twisted_lava_scheduler_daemon.py	2011-07-07 04:09:01 +0000
@@ -1,26 +1,32 @@ 
-import logging
 import os
-import sys
-
-from twisted.application import service
-from twisted.application import internet
-from twisted.python import filepath
-from twisted.internet import reactor
+
+from twisted.python import usage
+from twisted.plugin import IPlugin
+from twisted.application.service import IServiceMaker
+
+from zope.interface import implements
 
 from lava_scheduler_daemon.service import BoardSet
-os.environ['DJANGO_SETTINGS_MODULE'] = 'lava_server.settings.development'
-from lava_scheduler_daemon.dbjobsource import DatabaseJobSource
-
-application = service.Application("lava scheduler daemon")
-
-
-#source = DirectoryJobSource(filepath.FilePath('/tmp/lava-jobs'))
-source = DatabaseJobSource()
-board_set = BoardSet(source, 'fake-dispatcher', reactor)
-board_set.setServiceParent(application)
-
-logger = logging.getLogger('')
-handler = logging.StreamHandler(sys.stdout)
-handler.setFormatter(logging.Formatter("[%(name)s] %(message)s"))
-logger.addHandler(handler)
-logger.setLevel(logging.DEBUG)
+
+class MyServiceMaker(object):
+    implements(IServiceMaker, IPlugin)
+    tapname = "lava-scheduler-daemon"
+    description = "Run the LAVA Scheduler Daemon"
+    options = usage.Options
+
+    def makeService(self, options):
+        """
+        Construct a TCPServer from a factory defined in myproject.
+        """
+        os.environ['DJANGO_SETTINGS_MODULE'] = 'lava_server.settings.development'
+        from lava_scheduler_daemon.dbjobsource import DatabaseJobSource
+        from twisted.internet import reactor
+        source = DatabaseJobSource()
+        return BoardSet(source, 'lava-dispatch', reactor)
+
+
+# Now construct an object which *provides* the relevant interfaces
+# The name of this variable is irrelevant, as long as there is *some*
+# name bound to a provider of IPlugin and IServiceMaker.
+
+serviceMaker = MyServiceMaker()