2
# Copyright (C) 2015 Canonical
4
# This program is free software: you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation, either version 3 of the License, or
7
# (at your option) any later version.
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
# GNU General Public License for more details.
14
# You should have received a copy of the GNU General Public License
15
# along with this program. If not, see <http://www.gnu.org/licenses/>.
23
from uservice_utils.logging import configure_service_logging
24
from uservice_utils.queue import (
25
SimpleRabbitQueueWorker,
29
from core_image_builder.queue import (
30
create_connection_from_config,
31
CoreImageResultBuilder,
33
from core_image_builder import (
40
parser = argparse.ArgumentParser(description='Core image builder.')
44
default='core-service.conf',
45
help='Configuration file path'
47
args = parser.parse_args()
49
# Load configuration options.
50
config = configparser.ConfigParser()
51
config.read(args.conf)
56
config = read_config()
57
log_path = os.path.abspath(
58
os.path.join(__file__, '../../logs/core-image-builder.log')
60
configure_service_logging(
62
config['logstash'] if 'logstash' in config else None
64
logger = logging.getLogger(__name__)
65
logger.info('Started!', extra=constants.LOGGING_EXTRA)
67
connection = create_connection_from_config(config)
70
builder = CoreImageResultBuilder(connection)
71
retry_policy = DefaultRetryPolicy(
73
dead_queue='core.deadletters.{}'.format(constants.API_VERSION)
75
monitor = SimpleRabbitQueueWorker(
77
'core.image.{}'.format(constants.API_VERSION),
78
worker.ImageBuilderWorker(config, builder),
82
except KeyboardInterrupt: