Better organize the source file structure of the build manager and change it to choose a lifecycle manager based on the config

This commit is contained in:
Joseph Schorr 2014-11-25 16:14:44 -05:00
parent c48559ee3d
commit 660a640de6
12 changed files with 34 additions and 20 deletions

View file

@ -1,4 +1,3 @@
import argparse
import logging
from app import app, userfiles as user_files, build_logs, dockerfile_build_queue
@ -8,13 +7,23 @@ from buildman.server import BuilderServer
LOGGER = logging.getLogger(__name__)
if __name__ == '__main__':
logging.basicConfig(level=logging.DEBUG)
BUILD_MANAGERS = {
'enterprise': EnterpriseManager
}
parser = argparse.ArgumentParser()
parser.add_argument('--host', type=str, default='127.0.0.1', help='Host IP.')
args = parser.parse_args()
def run_build_manager():
build_manager_config = app.config.get('BUILD_MANAGER')
if build_manager_config is None:
return
manager_klass = BUILD_MANAGERS.get(build_manager_config[0])
if manager_klass is None:
return
server = BuilderServer(app.config['SERVER_HOSTNAME'], dockerfile_build_queue, build_logs,
user_files, EnterpriseManager)
server.run(args.host)
user_files, manager_klass)
server.run('0.0.0.0')
if __name__ == '__main__':
logging.basicConfig(level=logging.DEBUG)
run_build_manager()

View file

View file

@ -8,11 +8,11 @@ import re
from autobahn.wamp.exception import ApplicationError
from trollius.coroutines import From
from buildman.basecomponent import BaseComponent
from buildman.buildpack import BuildPackage, BuildPackageException
from buildman.buildstatus import StatusHandler
from buildman.server import BuildJobResult
from buildman.workererror import WorkerError
from buildman.component.basecomponent import BaseComponent
from buildman.jobutil.buildpack import BuildPackage, BuildPackageException
from buildman.jobutil.buildstatus import StatusHandler
from buildman.jobutil.workererror import WorkerError
from data.database import BUILD_PHASE

View file

View file

@ -1,9 +1,9 @@
import logging
import uuid
from buildman.component.basecomponent import BaseComponent
from buildman.component.buildcomponent import BuildComponent
from buildman.manager.basemanager import BaseManager
from buildman.basecomponent import BaseComponent
from buildman.buildcomponent import BuildComponent
from trollius.coroutines import From

View file

@ -11,7 +11,7 @@ from threading import Event
from trollius.coroutines import From
from datetime import datetime, timedelta
from buildman.buildjob import BuildJob, BuildJobLoadException
from buildman.jobutil.buildjob import BuildJob, BuildJobLoadException
from data.queue import WorkQueue
LOGGER = logging.getLogger(__name__)
@ -21,6 +21,9 @@ TIMEOUT_PERIOD_MINUTES = 20
JOB_TIMEOUT_SECONDS = 300
MINIMUM_JOB_EXTENSION = timedelta(minutes=2)
WEBSOCKET_PORT = 8080
CONTROLLER_PORT = 8181
class BuildJobResult(object):
""" Build job result enum """
INCOMPLETE = 'incomplete'
@ -166,8 +169,8 @@ class BuilderServer(object):
transport_factory.setProtocolOptions(failByDrop=True)
# Initialize the controller server and the WAMP server
create_wsgi_server(self._controller_app, loop=loop, host=host, port=8181)
yield From(loop.create_server(transport_factory, host, 8080))
create_wsgi_server(self._controller_app, loop=loop, host=host, port=CONTROLLER_PORT)
yield From(loop.create_server(transport_factory, host, WEBSOCKET_PORT))
# Initialize the work queue checker.
yield From(self._work_checker())

View file

@ -49,9 +49,9 @@ class DefaultConfig(object):
REGISTRY_TITLE = 'Quay.io'
REGISTRY_TITLE_SHORT = 'Quay.io'
CONTACT_INFO = [
'mailto:support@quay.io',
'irc://chat.freenode.net:6665/quayio',
'tel:+1-888-930-3475',
'mailto:support@quay.io',
'irc://chat.freenode.net:6665/quayio',
'tel:+1-888-930-3475',
'https://twitter.com/quayio',
]
@ -160,6 +160,8 @@ class DefaultConfig(object):
# Feature Flag: Whether users can be created (by non-super users).
FEATURE_USER_CREATION = True
BUILD_MANAGER = ('enterprise', {})
DISTRIBUTED_STORAGE_CONFIG = {
'local_eu': ['LocalStorage', {'storage_path': 'test/data/registry/eu'}],
'local_us': ['LocalStorage', {'storage_path': 'test/data/registry/us'}],