diff --git a/billingstack/central/service.py b/billingstack/central/service.py index e055b37..e03785f 100644 --- a/billingstack/central/service.py +++ b/billingstack/central/service.py @@ -14,10 +14,14 @@ # License for the specific language governing permissions and limitations # under the License. import functools +import sys + from oslo.config import cfg from billingstack.openstack.common import log as logging 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 import service as bs_service cfg.CONF.import_opt('central_topic', 'billingstack.central.rpcapi') @@ -295,3 +299,10 @@ class Service(rpc_service.Service): def delete_subscription(self, 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() diff --git a/billingstack/collector/service.py b/billingstack/collector/service.py index 906d6ac..d8d962a 100644 --- a/billingstack/collector/service.py +++ b/billingstack/collector/service.py @@ -18,10 +18,14 @@ A service that does calls towards the PGP web endpoint or so """ import functools +import sys + from oslo.config import cfg from billingstack.openstack.common import log as logging 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 import service as bs_service cfg.CONF.import_opt('host', 'billingstack.netconf') @@ -79,3 +83,10 @@ class Service(rpc_service.Service): return f(*args, **kw) setattr(self, name, _wrapper) return _wrapper + + +def launch(): + bs_service.prepare_service(sys.argv) + launcher = os_service.launch(Service(), + cfg.CONF['service:collector'].workers) + launcher.wait() diff --git a/billingstack/rater/service.py b/billingstack/rater/service.py index c450c6f..dbc4c63 100644 --- a/billingstack/rater/service.py +++ b/billingstack/rater/service.py @@ -13,10 +13,14 @@ # 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 oslo.config import cfg 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.rater import storage +from billingstack import service as bs_service cfg.CONF.import_opt('rater_topic', 'billingstack.rater.rpcapi') @@ -60,3 +64,10 @@ class Service(rpc_service.Service): def delete_usage(self, 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() diff --git a/billingstack/service.py b/billingstack/service.py index 182bdb9..f728a7a 100644 --- a/billingstack/service.py +++ b/billingstack/service.py @@ -15,11 +15,15 @@ # 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 eventlet +import sys + from oslo.config import cfg from billingstack.openstack.common import rpc from billingstack.openstack.common import context from billingstack.openstack.common import log from billingstack.openstack.common.rpc import service as rpc_service +from billingstack import utils cfg.CONF.register_opts([ @@ -42,6 +46,17 @@ class PeriodicService(rpc_service.Service): def prepare_service(argv=[]): + eventlet.monkey_patch() + utils.read_config('billingstack', sys.argv) + 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') log.setup('billingstack') diff --git a/bin/billingstack-biller b/bin/billingstack-biller deleted file mode 100644 index 0478d16..0000000 --- a/bin/billingstack-biller +++ /dev/null @@ -1,32 +0,0 @@ -#!/usr/bin/env python -# -# Author: Endre Karlson -# -# 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() diff --git a/bin/billingstack-central b/bin/billingstack-central deleted file mode 100644 index 2f4eed1..0000000 --- a/bin/billingstack-central +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env python -# Copyright 2012 Managed I.T. -# -# Author: Kiall Mac Innes -# -# 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() diff --git a/bin/billingstack-collector b/bin/billingstack-collector deleted file mode 100644 index 4a73d2c..0000000 --- a/bin/billingstack-collector +++ /dev/null @@ -1,32 +0,0 @@ -#!/usr/bin/env python -# -# Author: Endre Karlson -# -# 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() diff --git a/bin/billingstack-rater b/bin/billingstack-rater deleted file mode 100644 index 86df9b1..0000000 --- a/bin/billingstack-rater +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env python -# Copyright 2012 Managed I.T. -# -# Author: Kiall Mac Innes -# -# 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() diff --git a/setup.cfg b/setup.cfg index 019b3bc..9158949 100644 --- a/setup.cfg +++ b/setup.cfg @@ -28,12 +28,14 @@ scripts = bin/billingstack-db-manage bin/billingstack-manage bin/billingstack-api - bin/billingstack-central - bin/billingstack-biller - bin/billingstack-collector - bin/billingstack-rater [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 = sqlalchemy = billingstack.central.storage.impl_sqlalchemy:SQLAlchemyEngine