--- a/server/serverctl.py Tue Apr 10 17:03:19 2012 +0200
+++ b/server/serverctl.py Wed Apr 04 16:51:09 2012 +0200
@@ -35,6 +35,7 @@
from cubicweb.toolsutils import Command, CommandHandler, underline_title
from cubicweb.cwctl import CWCTL, check_options_consistency
from cubicweb.server import SOURCE_TYPES
+from cubicweb.server.repository import Repository
from cubicweb.server.serverconfig import (
USER_OPTIONS, ServerConfiguration, SourceConfiguration,
ask_source_config, generate_source_config)
@@ -633,7 +634,7 @@
class StartRepositoryCommand(Command):
"""Start a CubicWeb RQL server for a given instance.
- The server will be accessible through pyro
+ The server will be remotely accessible through pyro or ZMQ
<instance>
the identifier of the instance to initialize.
@@ -650,12 +651,30 @@
'default': None, 'choices': ('debug', 'info', 'warning', 'error'),
'help': 'debug if -D is set, error otherwise',
}),
+ ('address',
+ {'short': 'a', 'type': 'string', 'metavar': '<protocol>://<host>:<port>',
+ 'default': '',
+ 'help': ('specify a ZMQ URI on which to bind, or use "pyro://"'
+ 'to create a pyro-based repository'),
+ }),
)
+ def create_repo(self, config):
+ address = self['address']
+ if not address:
+ address = config.get('zmq-repository-address', 'pyro://')
+ if address.startswith('pyro://'):
+ from cubicweb.server.server import RepositoryServer
+ return RepositoryServer(config), config['host']
+ else:
+ from cubicweb.server.utils import TasksManager
+ from cubicweb.server.cwzmq import ZMQRepositoryServer
+ repo = Repository(config, TasksManager())
+ return ZMQRepositoryServer(repo), address
+
def run(self, args):
from logilab.common.daemon import daemonize, setugid
from cubicweb.cwctl import init_cmdline_log_threshold
- from cubicweb.server.server import RepositoryServer
appid = args[0]
debug = self['debug']
if sys.platform == 'win32' and not debug:
@@ -665,7 +684,7 @@
config = ServerConfiguration.config_for(appid, debugmode=debug)
init_cmdline_log_threshold(config, self['loglevel'])
# create the server
- server = RepositoryServer(config)
+ server, address = self.create_repo(config)
# ensure the directory where the pid-file should be set exists (for
# instance /var/run/cubicweb may be deleted on computer restart)
pidfile = config['pid-file']
@@ -679,7 +698,7 @@
if uid is not None:
setugid(uid)
server.install_sig_handlers()
- server.connect(config['host'], 0)
+ server.connect(address)
server.run()