progrium/gservice — Issue #41: change use of "name"; make setproctitle optional
Author: progrium
Created: 2011-12-24 04:54:06+00:00
State: open

setproctitle is cool but is not a necessary dependency. Let's use it if we have it, but otherwise just skip it. However, it's useful to have a name for a service instance. For example, what we name the pidfile. So we should have a good default name value that can be overwritten by the name option if present. And if setproctitle is present, we'll use this name to set the proc title.

The default name will be the module path of the service returned by the service factory: mypackage.myservice

If a configuration file is used, we'll use the filename prefix as the name suffix: dev.conf.py -> mypackage.myservice-dev

However, it's likely we won't know the service module path until we actually run because of the lazy eval nature of the service factory. In that case, we'll use the module path provided by the service lookup (which should be close if not that right module path for the service). Ie:

`gservice mypackage.myservice start`

Would mean we use "mypackage.myservice" despite what the service factory returns in that module.

Alternatively, if just a configuration file is used, we'll name it after the configuration file:

`gservice -C /path/to/myservice.conf.py start'

Would mean we use "myservice".