Added surveil-api command
Change-Id: Icd9598851f0203e4fe28e23bf1bccc7feb0d30bd
This commit is contained in:
parent
eb8c526ce0
commit
760d3530d9
@ -98,4 +98,7 @@ EXPOSE 5555
|
||||
# Mongodb
|
||||
EXPOSE 27017
|
||||
|
||||
# Surveil
|
||||
EXPOSE 8080
|
||||
|
||||
CMD ["/usr/bin/supervisord"]
|
||||
|
@ -1,2 +1,3 @@
|
||||
pecan>=0.5.0
|
||||
pymongo>=2.7.2
|
||||
wsme
|
@ -9,6 +9,10 @@ description-file =
|
||||
packages =
|
||||
surveil
|
||||
|
||||
[entry_points]
|
||||
console_scripts =
|
||||
surveil-api = surveil.cmd.api:main
|
||||
|
||||
[build_sphinx]
|
||||
source-dir = doc/source
|
||||
build-dir = doc/build
|
||||
|
@ -18,13 +18,13 @@ from surveil.api import hooks
|
||||
|
||||
# Server Specific Configurations
|
||||
server = {
|
||||
'port': '8080',
|
||||
'port': 8080,
|
||||
'host': '0.0.0.0'
|
||||
}
|
||||
|
||||
app_hooks = [
|
||||
hooks.DBHook(
|
||||
pymongo.MongoClient('172.17.0.2', 27017)
|
||||
pymongo.MongoClient('127.0.0.1', 27017)
|
||||
)
|
||||
]
|
||||
|
||||
|
0
surveil/cmd/__init__.py
Normal file
0
surveil/cmd/__init__.py
Normal file
55
surveil/cmd/api.py
Normal file
55
surveil/cmd/api.py
Normal file
@ -0,0 +1,55 @@
|
||||
# Copyright 2014 - Savoir-Faire Linux 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.
|
||||
|
||||
"""Starter script for the Surveil API service."""
|
||||
|
||||
import os
|
||||
from wsgiref import simple_server
|
||||
|
||||
import pecan
|
||||
|
||||
from surveil.api import app as api_app
|
||||
from surveil.api import config as api_config
|
||||
|
||||
|
||||
# TODO(aviau): Load conf from oslo
|
||||
def get_pecan_config():
|
||||
# Set up the pecan configuration
|
||||
filename = api_config.__file__.replace('.pyc', '.py')
|
||||
return pecan.configuration.conf_from_file(filename)
|
||||
|
||||
|
||||
def main():
|
||||
cfg = get_pecan_config()
|
||||
|
||||
app = api_app.setup_app(cfg)
|
||||
|
||||
# Create the WSGI server and start it
|
||||
host, port = cfg.server.host, cfg.server.port
|
||||
srv = simple_server.make_server(host, port, app)
|
||||
|
||||
# TODO(aviau): Logging. don't print :o)
|
||||
print ('Starting server in PID %s' % os.getpid())
|
||||
|
||||
if host == '0.0.0.0':
|
||||
print (
|
||||
'serving on 0.0.0.0:%(port)s, view at http://127.0.0.1:%(port)s' %
|
||||
dict(port=port)
|
||||
)
|
||||
else:
|
||||
print (
|
||||
'serving on http://%(host)s:%(port)s' % dict(host=host, port=port)
|
||||
)
|
||||
|
||||
srv.serve_forever()
|
@ -4,5 +4,4 @@ sphinxcontrib-pecanwsme>=0.8
|
||||
sphinxcontrib-httpdomain
|
||||
oslosphinx
|
||||
testrepository>=0.0.18
|
||||
mongomock
|
||||
wsme
|
||||
mongomock
|
@ -17,4 +17,4 @@ command=/bin/sh -c "service riemann start"
|
||||
command=/bin/sh -c "service mongodb start"
|
||||
|
||||
[program:surveil]
|
||||
command=/bin/sh -c "pecan serve /usr/local/lib/python3.4/dist-packages/surveil/api/config.py"
|
||||
command=/bin/sh -c "sleep 20 && surveil-api"
|
||||
|
Loading…
x
Reference in New Issue
Block a user