progrium / ginkgo

Python service microframework
http://ginkgo.readthedocs.org
MIT License
325 stars 51 forks source link

support module service lookup #35

Closed progrium closed 12 years ago

progrium commented 12 years ago

You should be able to specify a module instead of a configuration file such as:

gservice path.to.service.module start

This module will contain a service factory function (service()). Note that -C is not necessary, as it will attempt to use default configuration values. If -C is used, the configuration file will be used for configuration. However, if a service factory is in the configuration file, it will use that factory instead.

The canonical way to define a service factory is in the module that defines the top level service. You should always prefer to use the module lookup unless you need to override the service factory for some reason (however, if configuration is done correctly, you shouldn't have to).

Here is an example service module called package.myservice (in, say, package/myservice.py):

from gservice.core import Service

class MyService(Service):
    def do_start(self):
        pass

def service():
    return MyService()

Now you can run gservice package.myservice start

progrium commented 12 years ago

This is built into 0.5.0