All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ed Bartosh <ed.bartosh@linux.intel.com>
To: toaster@yoctoproject.org
Subject: [PATCH 15/26] toaster: reimplemented startBBServer method
Date: Thu, 12 Nov 2015 14:04:38 +0200	[thread overview]
Message-ID: <31ab3c728c59e23dd38b3d89065664646754462d.1447328915.git.ed.bartosh@linux.intel.com> (raw)
In-Reply-To: <cover.1447328915.git.ed.bartosh@linux.intel.com>
In-Reply-To: <cover.1447328915.git.ed.bartosh@linux.intel.com>

Rewritten LocalhostBEController.startBBServer to use
'toaster restart-bitbake' and read bitbake port number from
bitbake.lock.

Removed complicated logic of running oe-init-memres and looking for
bitbake port number in the logs.

Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
---
 .../toaster/bldcontrol/localhostbecontroller.py    | 82 +++++-----------------
 1 file changed, 18 insertions(+), 64 deletions(-)

diff --git a/bitbake/lib/toaster/bldcontrol/localhostbecontroller.py b/bitbake/lib/toaster/bldcontrol/localhostbecontroller.py
index 9a3c818..f321537 100644
--- a/bitbake/lib/toaster/bldcontrol/localhostbecontroller.py
+++ b/bitbake/lib/toaster/bldcontrol/localhostbecontroller.py
@@ -89,74 +89,28 @@ class LocalhostBEController(BuildEnvironmentController):
         # find our own toasterui listener/bitbake
         from toaster.bldcontrol.management.commands.loadconf import _reduce_canon_path
 
-        own_bitbake = _reduce_canon_path(os.path.join(os.path.dirname(os.path.abspath(__file__)), "../../../bin/bitbake"))
-
-        assert os.path.exists(own_bitbake) and os.path.isfile(own_bitbake)
-
-        logger.debug("localhostbecontroller: running the listener at %s" % own_bitbake)
-
-        toaster_ui_log_filepath = os.path.join(self.be.builddir, "toaster_ui.log")
-        # get the file length; we need to detect the _last_ start of the toaster UI, not the first
-        toaster_ui_log_filelength = 0
-        if os.path.exists(toaster_ui_log_filepath):
-            with open(toaster_ui_log_filepath, "w") as f:
-                f.seek(0, 2)    # jump to the end
-                toaster_ui_log_filelength = f.tell()
-
-        cmd = "bash -c \"source %s/oe-init-build-env %s 2>&1 >toaster_server.log && bitbake --read %s/conf/toaster-pre.conf --postread %s/conf/toaster.conf --server-only -t xmlrpc -B 0.0.0.0:0 2>&1 >>toaster_server.log \"" % (self.pokydirname, self.be.builddir, self.be.builddir, self.be.builddir)
-
-        port = "-1"
-        logger.debug("localhostbecontroller: starting builder \n%s\n" % cmd)
-
-        cmdoutput = self._shellcmd(cmd)
-        with open(self.be.builddir + "/toaster_server.log", "r") as f:
-            for i in f.readlines():
-                if i.startswith("Bitbake server address"):
-                    port = i.split(" ")[-1]
-                    logger.debug("localhostbecontroller: Found bitbake server port %s" % port)
-
-        cmd = "bash -c \"source %s/oe-init-build-env-memres -1 %s && DATABASE_URL=%s %s --observe-only -u toasterui --remote-server=0.0.0.0:-1 -t xmlrpc\"" % (self.pokydirname, self.be.builddir, self.dburl, own_bitbake)
-        with open(toaster_ui_log_filepath, "a+") as f:
-            p = subprocess.Popen(cmd, cwd = self.be.builddir, shell=True, stdout=f, stderr=f)
-
-        def _toaster_ui_started(filepath, filepos = 0):
-            if not os.path.exists(filepath):
-                return False
-            with open(filepath, "r") as f:
-                f.seek(filepos)
-                for line in f:
-                    if line.startswith("NOTE: ToasterUI waiting for events"):
-                        return True
-            return False
-
-        retries = 0
-        started = False
-        while not started and retries < 50:
-            started = _toaster_ui_started(toaster_ui_log_filepath, toaster_ui_log_filelength)
-            import time
-            logger.debug("localhostbecontroller: Waiting bitbake server to start")
-            time.sleep(0.5)
-            retries += 1
-
-        if not started:
-            toaster_ui_log = open(os.path.join(self.be.builddir, "toaster_ui.log"), "r").read()
-            toaster_server_log = open(os.path.join(self.be.builddir, "toaster_server.log"), "r").read()
-            raise BuildSetupException("localhostbecontroller: Bitbake server did not start in 25 seconds, aborting (Error: '%s' '%s')" % (toaster_ui_log, toaster_server_log))
-
-        logger.debug("localhostbecontroller: Started bitbake server")
-
-        while port == "-1":
-            # the port specification is "autodetect"; read the bitbake.lock file
-            with open("%s/bitbake.lock" % self.be.builddir, "r") as f:
-                for line in f.readlines():
+        toaster = _reduce_canon_path(os.path.join(os.path.dirname(os.path.abspath(__file__)), "../../../bin/toaster"))
+        assert os.path.exists(toaster) and os.path.isfile(toaster)
+
+        # restart bitbake server and toastergui observer
+        self._shellcmd("bash -c 'source %s restart-bitbake'" % toaster, self.be.builddir)
+        logger.debug("localhostbecontroller: restarted bitbake server")
+
+        # read port number from bitbake.lock
+        self.be.bbport = ""
+        bblock = os.path.join(self.be.builddir, 'bitbake.lock')
+        if os.path.exists(bblock):
+            with open(bblock) as fplock:
+                for line in fplock:
                     if ":" in line:
-                        port = line.split(":")[1].strip()
-                        logger.debug("localhostbecontroller: Autodetected bitbake port %s", port)
+                        self.be.bbport = line.split(":")[-1].strip()
+                        logger.debug("localhostbecontroller: bitbake port %s", self.be.bbport)
                         break
 
-        assert self.be.sourcedir and os.path.exists(self.be.builddir)
+        if not self.be.bbport:
+            raise BuildSetupException("localhostbecontroller: can't read bitbake port from %s" % bblock)
+
         self.be.bbaddress = "localhost"
-        self.be.bbport = port
         self.be.bbstate = BuildEnvironment.SERVER_STARTED
         self.be.save()
 
-- 
2.1.4



  parent reply	other threads:[~2015-11-12 12:38 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-12 11:55 [PATCH v4 00/26] toaster: 8279: Provide a single way of starting Toaster Ed Bartosh
2015-11-12 11:55 ` [PATCH 01/26] toaster: don't allow to run toaster as a script Ed Bartosh
2015-11-12 11:55 ` [PATCH 02/26] toaster: implement get-dburl command Ed Bartosh
2015-11-12 11:55 ` [PATCH 03/26] toaster: set DATABASE_URL in toaster script Ed Bartosh
2015-11-12 11:55 ` [PATCH 04/26] toaster: run bitbake the same way Ed Bartosh
2015-11-12 11:55 ` [PATCH 05/26] toaster: remove unused variable Ed Bartosh
2015-11-12 11:55 ` [PATCH 06/26] toaster: check for toaster configuration later Ed Bartosh
2015-11-12 11:55 ` [PATCH 07/26] toaster: use parent of the build dir Ed Bartosh
2015-11-12 11:55 ` [PATCH 08/26] toaster: make runbuilds to loop Ed Bartosh
2015-11-12 12:04 ` [PATCH 09/26] toaster: start 'manage.py runbuilds' in the script Ed Bartosh
2015-11-12 12:04 ` [PATCH 10/26] toaster: update brbe and project attributes Ed Bartosh
2015-11-12 12:04 ` [PATCH 11/26] toaster: implement stop_bitbake function Ed Bartosh
2015-11-12 12:04 ` [PATCH 12/26] toaster: implement start_bitbake function Ed Bartosh
2015-11-12 12:04 ` [PATCH 13/26] toaster: implement 'toaster restart-bitbake' Ed Bartosh
2015-11-12 12:04 ` [PATCH 14/26] toaster: remove _setupBE function Ed Bartosh
2015-11-12 12:04 ` Ed Bartosh [this message]
2015-11-12 12:04 ` [PATCH 16/26] toaster: remove stopBBServer API Ed Bartosh
2015-11-12 12:04 ` [PATCH 17/26] toaster: do not terminate bb server Ed Bartosh
2015-11-12 12:04 ` [PATCH 18/26] toaster: remove usage of BUILD_MODE variable Ed Bartosh
2015-11-12 12:04 ` [PATCH 19/26] toaster: do not create duplicate HelpText objects Ed Bartosh
2015-11-12 12:04 ` [PATCH 20/26] toaster: buildinfohelper Broaden the toaster created recipe data case Ed Bartosh
2015-11-12 12:04 ` [PATCH 21/26] toaster: implement BitbakeController.getVariable Ed Bartosh
2015-11-12 12:04 ` [PATCH 22/26] toaster: set varibales on bitbake server Ed Bartosh
2015-11-12 12:04 ` [PATCH 23/26] toaster: remove writeConfFile API Ed Bartosh
2015-11-12 12:04 ` [PATCH 24/26] toaster: stop using toaster-pre.conf Ed Bartosh
2015-11-12 12:04 ` [PATCH 25/26] toaster: remove SDKMACHINE from project variables Ed Bartosh
2015-11-12 12:04 ` [PATCH 26/26] toaster: get rid of complicated heuristics Ed Bartosh
2015-11-16 18:40 ` [PATCH v4 00/26] toaster: 8279: Provide a single way of starting Toaster Brian Avery

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=31ab3c728c59e23dd38b3d89065664646754462d.1447328915.git.ed.bartosh@linux.intel.com \
    --to=ed.bartosh@linux.intel.com \
    --cc=toaster@yoctoproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.