[bitbake-devel] [PATCH 09/11] toaster: move startup checks to a better place

Elliot Smith elliot.smith at intel.com
Thu Dec 17 16:48:54 UTC 2015


From: Ed Bartosh <ed.bartosh at linux.intel.com>

Moved addr:port, bitbake.lock and toastermain.pid checks
to the place where the rest of Toaster starting happens.

Signed-off-by: Ed Bartosh <ed.bartosh at linux.intel.com>
Signed-off-by: Elliot Smith <elliot.smith at intel.com>
---
 bin/toaster | 49 +++++++++++++++++++++++--------------------------
 1 file changed, 23 insertions(+), 26 deletions(-)

diff --git a/bin/toaster b/bin/toaster
index 1f4c400..6dd20c1 100755
--- a/bin/toaster
+++ b/bin/toaster
@@ -288,36 +288,33 @@ fi
 
 echo "The system will $CMD."
 
-# check if addr:port is not in use
-if [ "$CMD" == 'start' ]; then
-    $MANAGE checksocket "0.0.0.0:$WEB_PORT" || return 1
-fi
-
-# Make sure it's safe to run by checking bitbake lock
-
-lock=1
-if [ -e $BUILDDIR/bitbake.lock ]; then
-    python -c "import fcntl; fcntl.flock(open(\"$BUILDDIR/bitbake.lock\"), fcntl.LOCK_EX|fcntl.LOCK_NB)" 2>/dev/null || lock=0
-fi
-
-if [ ${CMD} = 'start' ] && [ $lock -eq 0 ]; then
-    echo "Error: bitbake lock state error. File locks show that the system is on." 1>&2
-    echo "Please wait for the current build to finish, stop and then start the system again." 1>&2
-    return 3
-fi
-
-if [ ${CMD} = 'start' ] && [ -e $BUILDDIR/.toastermain.pid ] && kill -0 `cat $BUILDDIR/.toastermain.pid`; then
-    echo "Warning: bitbake appears to be dead, but the Toaster web server is running." 1>&2
-    echo " Something fishy is going on." 1>&2
-    echo "Cleaning up the web server to start from a clean slate."
-    webserverKillAll
-fi
-
-
 # Execute the commands
 
 case $CMD in
     start )
+        # check if addr:port is not in use
+        if [ "$CMD" == 'start' ]; then
+             $MANAGE checksocket "0.0.0.0:$WEB_PORT" || return 1
+        fi
+
+        # Make sure it's safe to start by checking bitbake lock
+        if [ -e $BUILDDIR/bitbake.lock ]; then
+            python -c "import fcntl; fcntl.flock(open(\"$BUILDDIR/bitbake.lock\"), fcntl.LOCK_EX|fcntl.LOCK_NB)" 2>/dev/null
+            if [ $? -ne 0 ] ; then
+                echo "Error: bitbake lock state error. File locks show that the system is on." 1>&2
+                echo "Please wait for the current build to finish, stop and then start the system again." 1>&2
+                return 3
+            fi
+        fi
+
+        # kill Toaster web server if it's alive
+        if [ -e $BUILDDIR/.toastermain.pid ] && kill -0 `cat $BUILDDIR/.toastermain.pid`; then
+            echo "Warning: bitbake appears to be dead, but the Toaster web server is running." 1>&2
+            echo " Something fishy is going on." 1>&2
+            echo "Cleaning up the web server to start from a clean slate."
+            webserverKillAll
+        fi
+
         # Create configuration file
         conf=${BUILDDIR}/conf/toaster.conf
         echo "# Created by toaster start script" > $conf
-- 
1.9.3

---------------------------------------------------------------------
Intel Corporation (UK) Limited
Registered No. 1134945 (England)
Registered Office: Pipers Way, Swindon SN3 1RJ
VAT No: 860 2173 47

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.




More information about the bitbake-devel mailing list