Use console scripts for backends

Change-Id: Ib82a81189f7ae43749fd3e7a4171a23f69b7cae6
This commit is contained in:
Endre Karlson 2013-06-02 14:00:10 +02:00
parent 61fb5dcdd2
commit 84450e6d22
9 changed files with 54 additions and 134 deletions

View File

@ -14,10 +14,14 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import functools import functools
import sys
from oslo.config import cfg from oslo.config import cfg
from billingstack.openstack.common import log as logging from billingstack.openstack.common import log as logging
from billingstack.openstack.common.rpc import service as rpc_service from billingstack.openstack.common.rpc import service as rpc_service
from billingstack.openstack.common import service as os_service
from billingstack.central import storage from billingstack.central import storage
from billingstack import service as bs_service
cfg.CONF.import_opt('central_topic', 'billingstack.central.rpcapi') cfg.CONF.import_opt('central_topic', 'billingstack.central.rpcapi')
@ -295,3 +299,10 @@ class Service(rpc_service.Service):
def delete_subscription(self, ctxt, id_): def delete_subscription(self, ctxt, id_):
return self.storage_conn.delete_subscription(ctxt, id_) return self.storage_conn.delete_subscription(ctxt, id_)
def launch():
bs_service.prepare_service(sys.argv)
launcher = os_service.launch(Service(),
cfg.CONF['service:central'].workers)
launcher.wait()

View File

@ -18,10 +18,14 @@ A service that does calls towards the PGP web endpoint or so
""" """
import functools import functools
import sys
from oslo.config import cfg from oslo.config import cfg
from billingstack.openstack.common import log as logging from billingstack.openstack.common import log as logging
from billingstack.openstack.common.rpc import service as rpc_service from billingstack.openstack.common.rpc import service as rpc_service
from billingstack.openstack.common import service as os_service
from billingstack.central.rpcapi import CentralAPI from billingstack.central.rpcapi import CentralAPI
from billingstack import service as bs_service
cfg.CONF.import_opt('host', 'billingstack.netconf') cfg.CONF.import_opt('host', 'billingstack.netconf')
@ -79,3 +83,10 @@ class Service(rpc_service.Service):
return f(*args, **kw) return f(*args, **kw)
setattr(self, name, _wrapper) setattr(self, name, _wrapper)
return _wrapper return _wrapper
def launch():
bs_service.prepare_service(sys.argv)
launcher = os_service.launch(Service(),
cfg.CONF['service:collector'].workers)
launcher.wait()

View File

@ -13,10 +13,14 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import sys
from oslo.config import cfg from oslo.config import cfg
from billingstack.openstack.common import log as logging from billingstack.openstack.common import log as logging
from billingstack.openstack.common import service as os_service
from billingstack.openstack.common.rpc import service as rpc_service from billingstack.openstack.common.rpc import service as rpc_service
from billingstack.rater import storage from billingstack.rater import storage
from billingstack import service as bs_service
cfg.CONF.import_opt('rater_topic', 'billingstack.rater.rpcapi') cfg.CONF.import_opt('rater_topic', 'billingstack.rater.rpcapi')
@ -60,3 +64,10 @@ class Service(rpc_service.Service):
def delete_usage(self, ctxt, id_): def delete_usage(self, ctxt, id_):
return self.storage_conn.delete_usage(ctxt, id_) return self.storage_conn.delete_usage(ctxt, id_)
def launch():
bs_service.prepare_service(sys.argv)
launcher = os_service.launch(Service(),
cfg.CONF['service:rater'].workers)
launcher.wait()

View File

@ -15,11 +15,15 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import eventlet
import sys
from oslo.config import cfg from oslo.config import cfg
from billingstack.openstack.common import rpc from billingstack.openstack.common import rpc
from billingstack.openstack.common import context from billingstack.openstack.common import context
from billingstack.openstack.common import log from billingstack.openstack.common import log
from billingstack.openstack.common.rpc import service as rpc_service from billingstack.openstack.common.rpc import service as rpc_service
from billingstack import utils
cfg.CONF.register_opts([ cfg.CONF.register_opts([
@ -42,6 +46,17 @@ class PeriodicService(rpc_service.Service):
def prepare_service(argv=[]): def prepare_service(argv=[]):
eventlet.monkey_patch()
utils.read_config('billingstack', sys.argv)
rpc.set_defaults(control_exchange='billingstack') rpc.set_defaults(control_exchange='billingstack')
cfg.set_defaults(log.log_opts,
default_log_levels=['amqplib=WARN',
'qpid.messaging=INFO',
'sqlalchemy=WARN',
'keystoneclient=INFO',
'stevedore=INFO',
'eventlet.wsgi.server=WARN'
])
cfg.CONF(argv[1:], project='billingstack') cfg.CONF(argv[1:], project='billingstack')
log.setup('billingstack') log.setup('billingstack')

View File

@ -1,32 +0,0 @@
#!/usr/bin/env python
#
# Author: Endre Karlson <endre.karlson@gmail.com>
#
# 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
import eventlet
from oslo.config import cfg
from billingstack.openstack.common import log as logging
from billingstack.openstack.common import service
from billingstack import utils
from billingstack.biller import service as biller_service
eventlet.monkey_patch()
utils.read_config('billingstack', sys.argv)
logging.setup('billingstack')
launcher = service.launch(biller_service.Service(),
cfg.CONF['service:biller'].workers)
launcher.wait()

View File

@ -1,33 +0,0 @@
#!/usr/bin/env python
# Copyright 2012 Managed I.T.
#
# Author: Kiall Mac Innes <kiall@managedit.ie>
#
# 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
import eventlet
from oslo.config import cfg
from billingstack.openstack.common import log as logging
from billingstack.openstack.common import service
from billingstack import utils
from billingstack.central import service as central_service
eventlet.monkey_patch()
utils.read_config('billingstack', sys.argv)
logging.setup('billingstack')
launcher = service.launch(central_service.Service(),
cfg.CONF['service:central'].workers)
launcher.wait()

View File

@ -1,32 +0,0 @@
#!/usr/bin/env python
#
# Author: Endre Karlson <endre.karlson@gmail.com>
#
# 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
import eventlet
from oslo.config import cfg
from billingstack.openstack.common import log as logging
from billingstack.openstack.common import service
from billingstack import utils
from billingstack.collector import service as collector_service
eventlet.monkey_patch()
utils.read_config('billingstack', sys.argv)
logging.setup('billingstack')
launcher = service.launch(collector_service.Service(),
cfg.CONF['service:collector'].workers)
launcher.wait()

View File

@ -1,33 +0,0 @@
#!/usr/bin/env python
# Copyright 2012 Managed I.T.
#
# Author: Kiall Mac Innes <kiall@managedit.ie>
#
# 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
import eventlet
from oslo.config import cfg
from billingstack.openstack.common import log as logging
from billingstack.openstack.common import service
from billingstack import utils
from billingstack.rater import service as rater_service
eventlet.monkey_patch()
utils.read_config('billingstack', sys.argv)
logging.setup('billingstack')
launcher = service.launch(rater_service.Service(),
cfg.CONF['service:rater'].workers)
launcher.wait()

View File

@ -28,12 +28,14 @@ scripts =
bin/billingstack-db-manage bin/billingstack-db-manage
bin/billingstack-manage bin/billingstack-manage
bin/billingstack-api bin/billingstack-api
bin/billingstack-central
bin/billingstack-biller
bin/billingstack-collector
bin/billingstack-rater
[entry_points] [entry_points]
console_scripts =
billingstack-biller = billingstack.biller.service:launch
billingstack-central = billingstack.central.service:launch
billingstack-collector = billingstack.collector.service:launch
billingstack-rater = billingstack.rater.service:launch
billingstack.central.storage = billingstack.central.storage =
sqlalchemy = billingstack.central.storage.impl_sqlalchemy:SQLAlchemyEngine sqlalchemy = billingstack.central.storage.impl_sqlalchemy:SQLAlchemyEngine