summaryrefslogtreecommitdiffstats
path: root/bin/bitbake
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2011-06-08 13:08:52 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2011-06-08 13:08:52 +0100
commitd21d5954d0c08b1c80b72c5f37becc2e58ec916a (patch)
tree1e6adc292c780bcc3311b28908a96bac439a2ae6 /bin/bitbake
parent93059e36200b61f87f61578d9774172212446644 (diff)
downloadbitbake-d21d5954d0c08b1c80b72c5f37becc2e58ec916a.tar.gz
bitbake/server: Move server specific code into the server backend and create a server API
Move the server implementation specific code into the server backend where it belongs and replace this with a set of object method calls which establish the server, detach it and then connect to it using appropriate IPC. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bin/bitbake')
-rwxr-xr-xbin/bitbake65
1 files changed, 27 insertions, 38 deletions
diff --git a/bin/bitbake b/bin/bitbake
index c22e29ad1..1ed46d9b5 100755
--- a/bin/bitbake
+++ b/bin/bitbake
@@ -29,7 +29,6 @@ sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(__file__)),
import optparse
import warnings
-import signal
from traceback import format_exception
try:
import bb
@@ -40,10 +39,9 @@ import bb.msg
from bb import cooker
from bb import ui
from bb import server
-from bb.server.process import ProcessServer, ServerCommunicator, ProcessEventQueue
-
-from Queue import Empty
-from multiprocessing import Queue, Pipe
+#from bb.server import none
+from bb.server import process
+#from bb.server import xmlrpc
__version__ = "1.13.0"
logger = logging.getLogger("BitBake")
@@ -175,6 +173,10 @@ Default BBFILES are the .bb files in the current directory.""")
ui_main = get_ui(configuration)
+ # Save a logfile for cooker into the current working directory. When the
+ # server is daemonized this logfile will be truncated.
+ cooker_logfile = os.path.join(os.getcwd(), "cooker.log")
+
bb.utils.init_logger(bb.msg, configuration.verbose, configuration.debug,
configuration.debug_domains)
@@ -187,45 +189,32 @@ Default BBFILES are the .bb files in the current directory.""")
# of the UIs (e.g. for DISPLAY, etc.)
bb.utils.clean_environment()
- # establish communication channels. We use bidirectional pipes for
- # ui <--> server command/response pairs
- # and a queue for server -> ui event notifications
- #
- ui_channel, server_channel = Pipe()
- event_queue = ProcessEventQueue()
+ #server = bb.server.none.BitBakeServer()
+ server = bb.server.process.BitBakeServer()
+ #server = bb.server.xmlrpc.BitBakeServer()
+
+ server.initServer()
+ idle = server.getServerIdleCB()
- server = ProcessServer(server_channel, event_queue, configuration)
- server.start()
+ cooker = bb.cooker.BBCooker(configuration, idle)
+ cooker.parseCommandLine()
+
+ server.addcooker(cooker)
+ server.saveConnectionDetails()
+ server.detach(cooker_logfile)
+
+ # Should no longer need to ever reference cooker
+ del cooker
logger.removeHandler(handler)
- def shutdown(force=False):
- signal.signal(signal.SIGINT, signal.SIG_IGN)
- server.stop()
- if force:
- server.join(0.5)
- if server.is_alive():
- server.terminate()
- server.join()
- else:
- server.join()
- while True:
- try:
- event = event_queue.get(block=False)
- except (Empty, IOError):
- break
- if isinstance(event, logging.LogRecord):
- logger.handle(event)
- ui_channel.close()
- event_queue.close()
- if force:
- sys.exit(1)
-
- signal.signal(signal.SIGTERM, lambda i, s: shutdown(force=True))
+ # Setup a connection to the server (cooker)
+ server_connection = server.establishConnection()
+
try:
- return ui_main(ServerCommunicator(ui_channel), event_queue)
+ return server.launchUI(ui_main, server_connection.connection, server_connection.events)
finally:
- shutdown()
+ server_connection.terminate()
return 1