X-Git-Url: https://git.llucax.com/software/pymin.git/blobdiff_plain/296d853cc95fd5bef262248cfe21b507abd26a4f..c98aa34adf8a6e45634f0fb18552fdddb54ebf55:/pymind?ds=inline diff --git a/pymind b/pymind index 27a9722..d40c80f 100755 --- a/pymind +++ b/pymind @@ -1,8 +1,32 @@ #!/usr/bin/env python # vim: set encoding=utf-8 et sw=4 sts=4 : +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() +# exit status +EXIT_NO_SERVICE = 1 + +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(EXIT_NO_SERVICE) + 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()