Implemented marconi-server entry point
This patch adds the first console_script for marconi server.
In order to use it it's enough to run setup.py either using develop or
install.
Side changes:
The config now uses sys.argv[1:] if no custom cli args have been
set.
Implements blueprint transport-base
Change-Id: I15732129d66b32fca2b818e9105b17f541094983
This commit is contained in:
@@ -11,4 +11,5 @@ port = 8888
|
|||||||
;port = 9999
|
;port = 9999
|
||||||
|
|
||||||
[drivers:storage:mongodb]
|
[drivers:storage:mongodb]
|
||||||
uri = mongodb://db1.example.net,db2.example.net:2500/?replicaSet=test&ssl=true&w=majority
|
uri = mongodb://db1.example.net,db2.example.net:2500/?replicaSet=test&ssl=true&w=majority
|
||||||
|
database = marconi
|
||||||
|
|||||||
0
marconi/bin/__init__.py
Normal file
0
marconi/bin/__init__.py
Normal file
33
marconi/bin/server.py
Normal file
33
marconi/bin/server.py
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
# Copyright (c) 2013 Red Hat, Inc.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||||
|
# implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
import sys
|
||||||
|
|
||||||
|
from marconi import bootstrap
|
||||||
|
|
||||||
|
|
||||||
|
def fail(returncode, e):
|
||||||
|
sys.stderr.write("ERROR: %s\n" % e)
|
||||||
|
sys.exit(returncode)
|
||||||
|
|
||||||
|
|
||||||
|
def run():
|
||||||
|
try:
|
||||||
|
server = bootstrap.Bootstrap()
|
||||||
|
server.run()
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
fail(1, '... terminating marconi')
|
||||||
|
except RuntimeError as e:
|
||||||
|
fail(1, e)
|
||||||
@@ -52,12 +52,15 @@ A call to `.load` without an argument looks up for the default ones:
|
|||||||
~/.marconi/marconi.conf
|
~/.marconi/marconi.conf
|
||||||
/etc/marconi/marconi.conf
|
/etc/marconi/marconi.conf
|
||||||
|
|
||||||
The global config variables, if any, can also be read from the command
|
Global config variables, if any, will be read from the command line using
|
||||||
line arguments by saving them before a `.load` call:
|
sys.argv[:1]. If needed, this can be overwritten by calling `set_cli`
|
||||||
|
before calling `.load`
|
||||||
|
|
||||||
cfg_handle.set_cli(sys.argv[1:])
|
cfg_handle.set_cli([])
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import sys
|
||||||
|
|
||||||
from oslo.config import cfg
|
from oslo.config import cfg
|
||||||
|
|
||||||
|
|
||||||
@@ -73,7 +76,7 @@ def _init():
|
|||||||
__setattr__ = dict.__setitem__
|
__setattr__ = dict.__setitem__
|
||||||
|
|
||||||
conf = cfg.ConfigOpts()
|
conf = cfg.ConfigOpts()
|
||||||
my = Obj(args=[])
|
my = Obj(args=sys.argv[1:])
|
||||||
|
|
||||||
def namespace(name, title=None):
|
def namespace(name, title=None):
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -51,6 +51,8 @@ class TestBase(testtools.TestCase):
|
|||||||
|
|
||||||
:returns: Project's config object.
|
:returns: Project's config object.
|
||||||
"""
|
"""
|
||||||
|
# Reset CLI
|
||||||
|
cfg.set_cli([])
|
||||||
cfg.load(self.conf_path(filename))
|
cfg.load(self.conf_path(filename))
|
||||||
return cfg
|
return cfg
|
||||||
|
|
||||||
|
|||||||
4
setup.py
4
setup.py
@@ -38,4 +38,8 @@ setuptools.setup(
|
|||||||
install_requires=requires,
|
install_requires=requires,
|
||||||
dependency_links=dependency_links,
|
dependency_links=dependency_links,
|
||||||
cmdclass=common_setup.get_cmdclass(),
|
cmdclass=common_setup.get_cmdclass(),
|
||||||
|
entry_points={
|
||||||
|
'console_scripts':
|
||||||
|
['marconi-server = marconi.bin.server:run']
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user