Skip to content
This repository has been archived by the owner on Mar 22, 2018. It is now read-only.

Commit

Permalink
storage: commissaire-storage-service now installs as a bin.
Browse files Browse the repository at this point in the history
  • Loading branch information
ashcrow authored and mbarnes committed Sep 29, 2016
1 parent dd30d7d commit 67140e6
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 5 deletions.
8 changes: 8 additions & 0 deletions conf/storage.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"storage-handlers": [{
"name": "commissaire.storage.etcd",
"server_url": "https://127.0.0.1:2379",
"models": ["*"]
}
]
}
7 changes: 6 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,10 @@ def extract_requirements(filename):
install_requires=install_requires,
tests_require=test_require,
package_dir={'': 'src'},
packages=find_packages('src')
packages=find_packages('src'),
entry_points={
'console_scripts': [
'commissaire-storage-service = commissaire_service.storage:main',
],
}
)
34 changes: 30 additions & 4 deletions src/commissaire_service/storage/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,12 +197,38 @@ def on_list(self, message, model_type_name):
return [model_instance.to_json() for model_instance in model_list]


if __name__ == '__main__':
def main(): # pragma: no cover
"""
Main entry point.
"""
import argparse

parser = argparse.ArgumentParser()
parser.add_argument(
'-c', '--config', required=True, type=str,
help='Configuration file to use.')
parser.add_argument(
'--bus-exchange', type=str, default='commissaire',
help='Message bus exchange name.')
parser.add_argument(
'--bus-uri', type=str, metavar='BUS_URI',
default='redis://127.0.0.1:6379/', # FIXME: Remove before release
help=(
'Message bus connection URI. See:'
'http://kombu.readthedocs.io/en/latest/userguide/connections.html')
)

args = parser.parse_args()

try:
service = StorageService(
exchange_name='commissaire',
connection_url='redis://127.0.0.1:6379/',
config_file=None)
exchange_name=args.bus_exchange,
connection_url=args.bus_uri,
config_file=args.config)
service.run()
except KeyboardInterrupt:
pass


if __name__ == '__main__': # pragma: no cover
main()

0 comments on commit 67140e6

Please sign in to comment.