]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
add beginning queen code
authorBrian Warner <warner@lothar.com>
Thu, 30 Nov 2006 22:39:24 +0000 (15:39 -0700)
committerBrian Warner <warner@lothar.com>
Thu, 30 Nov 2006 22:39:24 +0000 (15:39 -0700)
allmydata/queen.py [new file with mode: 0644]
queen.tac [new file with mode: 0644]

diff --git a/allmydata/queen.py b/allmydata/queen.py
new file mode 100644 (file)
index 0000000..338af2c
--- /dev/null
@@ -0,0 +1,29 @@
+
+from foolscap import Tub, Referenceable
+from twisted.application import service
+from twisted.python import log
+import os.path
+
+class Roster(service.MultiService, Referenceable):
+    pass
+
+class Queen(service.MultiService):
+    CERTFILE = "queen.pem"
+
+    def __init__(self):
+        service.MultiService.__init__(self)
+        if os.path.exists(self.CERTFILE):
+            self.tub = Tub(certData=open(self.CERTFILE, "rb").read())
+        else:
+            self.tub = Tub()
+            f = open(self.CERTFILE, "wb")
+            f.write(self.tub.getCertData())
+            f.close()
+        self.urls = {}
+        r = Roster()
+        r.setServiceParent(self)
+        self.urls["roster"] = self.tub.registerReference(r, "roster")
+
+    def startService(self):
+        service.MultiService.startService(self)
+        log.msg("queen running, roster is at %s" % self.urls["roster"])
diff --git a/queen.tac b/queen.tac
new file mode 100644 (file)
index 0000000..ac9b9b1
--- /dev/null
+++ b/queen.tac
@@ -0,0 +1,9 @@
+# -*- python -*-
+
+from allmydata import queen
+from twisted.application import service
+
+c = queen.Queen()
+
+application = service.Application("allmydata_queen")
+c.setServiceParent(application)