Revision
11813
Author
sagen@apple.com
Date
2013-10-14 13:34:03 -0700 (Mon, 14 Oct 2013)

Log Message

Allow manhole usage in "Single" mode

Modified Paths

Diff

Modified: CalendarServer/trunk/calendarserver/tap/caldav.py (11812 => 11813)


--- CalendarServer/trunk/calendarserver/tap/caldav.py	2013-10-14 20:33:47 UTC (rev 11812)
+++ CalendarServer/trunk/calendarserver/tap/caldav.py	2013-10-14 20:34:03 UTC (rev 11813)
@@ -1212,6 +1212,28 @@
             else:
                 groupCacher = None
 
+            # Optionally enable Manhole access
+            if config.Manhole.Enabled:
+                try:
+                    from twisted.conch.manhole_tap import makeService as manholeMakeService
+                    portString = "tcp:%d:interface=127.0.0.1" % (config.Manhole.StartingPortNumber,)
+                    manholeService = manholeMakeService({
+                        "sshPort" : None,
+                        "telnetPort" : portString,
+                        "namespace" : {
+                            "config" : config,
+                            "service" : result,
+                            "store" : store,
+                            "directory" : directory,
+                            },
+                        "passwd" : config.Manhole.PasswordFilePath,
+                    })
+                    manholeService.setServiceParent(result)
+                    # Using print(because logging isn't ready at this point)
+                    print("Manhole access enabled: %s" % (portString,))
+                except ImportError:
+                    print("Manhole access could not enabled because manhole_tap could not be imported")
+
             def decorateTransaction(txn):
                 txn._pushDistributor = pushDistributor
                 txn._rootResource = result.rootResource