]> git.llucax.com Git - software/pymin.git/blobdiff - pymind
Add logging to pymin.service module (refs #27).
[software/pymin.git] / pymind
diff --git a/pymind b/pymind
index 37feab9243c9b201251f6add59aa7227c214dc68..c29dabb4b7acc9391408f055861044ceb9bc0682 100755 (executable)
--- a/pymind
+++ b/pymind
@@ -1,8 +1,29 @@
 #!/usr/bin/env python
 # vim: set encoding=utf-8 et sw=4 sts=4 :
 
-from pymindaemon import PyminDaemon
+import sys
+from pymin.pymindaemon import PyminDaemon
+from pymin.dispatcher import Handler
+from pymin.service import load_service, LoadError
 import config
 
-PyminDaemon(config.routes, config.bind_addr).run()
+class Root(Handler):
+    pass
+
+def build_root(config):
+    # TODO check services dependencies
+    services = dict()
+    for service in config.services:
+        try:
+            s = load_service(service, config.services_dirs)
+        except LoadError, e:
+            sys.stderr.write("Can't find service called '%s'\n" % service)
+            sys.exit(1)
+        services[service] = s
+    root = Root()
+    for name, service in services.items():
+        setattr(root, name, service.get_service(config))
+    return root
+
+PyminDaemon(build_root(config), config.bind_addr).run()