summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexandru DAMIAN <alexandru.damian@intel.com>2013-12-10 18:24:18 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2014-01-07 13:00:29 +0000
commitf43d284e7ae752049711d8215a6020bee6966d45 (patch)
treecab2a8ec2ad126b6efd626a6751a91b81d5744d8
parent34afbdd0fc809b8fb20696aeef3e6a61d6812e16 (diff)
downloadbitbake-f43d284e7ae752049711d8215a6020bee6966d45.tar.gz
toaster: add two-stage commit startup logic
Toaster start script lunches multiple process components of the toaster system. This patch adds logic into the startup script to safely fail startup and do proper cleanup on any error that may happen during system start. Bitbake needs to return 0 if it will successfully lunches the server-mode. Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rwxr-xr-xbin/bitbake1
-rwxr-xr-xbin/toaster45
2 files changed, 36 insertions, 10 deletions
diff --git a/bin/bitbake b/bin/bitbake
index d27fe849f..cbfd2c97b 100755
--- a/bin/bitbake
+++ b/bin/bitbake
@@ -343,6 +343,7 @@ def main():
server_connection.terminate()
else:
print("server address: %s, server port: %s" % (server.serverImpl.host, server.serverImpl.port))
+ return 0
return 1
diff --git a/bin/toaster b/bin/toaster
index fc59fe554..38e71acc2 100755
--- a/bin/toaster
+++ b/bin/toaster
@@ -51,6 +51,11 @@ function webserverStartAll()
fi
if [ $retval -eq 0 ]; then
python $BBBASEDIR/lib/toaster/manage.py runserver 0.0.0.0:8000 </dev/null >${BUILDDIR}/toaster_web.log 2>&1 & echo $! >${BUILDDIR}/.toastermain.pid
+ sleep 1
+ if ! cat "${BUILDDIR}/.toastermain.pid" | xargs -I{} kill -0 {} ; then
+ retval=1
+ rm "${BUILDDIR}/.toastermain.pid"
+ fi
fi
return $retval
}
@@ -120,9 +125,13 @@ else
fi
NOTOASTERUI=0
-if [ "x$2" == "xnoui" ]; then
- NOTOASTERUI=1
-fi
+for param in $*; do
+ case $param in
+ noui )
+ NOTOASTERUI=1
+ ;;
+ esac
+done
echo "The system will $CMD."
@@ -157,22 +166,38 @@ fi
case $CMD in
start )
+ start_success=1
addtoConfiguration "INHERIT+=\"toaster buildhistory\"" toaster.conf
- webserverStartAll || return 4
+ if ! webserverStartAll; then
+ echo "Failed ${CMD}."
+ return 4
+ fi
unset BBSERVER
bitbake --postread conf/toaster.conf --server-only -t xmlrpc -B localhost:8200
- export BBSERVER=localhost:8200
- if [ $NOTOASTERUI == 0 ]; then # we start the TOASTERUI only if not inhibited
- bitbake --observe-only -u toasterui >${BUILDDIR}/toaster_ui.log 2>&1 & echo $! >${BUILDDIR}/.toasterui.pid
+ if [ $? -ne 0 ]; then
+ start_success=0
+ echo "Bitbake server start failed"
+ else
+ export BBSERVER=localhost:8200
+ if [ $NOTOASTERUI == 0 ]; then # we start the TOASTERUI only if not inhibited
+ bitbake --observe-only -u toasterui >${BUILDDIR}/toaster_ui.log 2>&1 & echo $! >${BUILDDIR}/.toasterui.pid
+ fi
+ fi
+ if [ $start_success -eq 1 ]; then
+ # set fail safe stop system on terminal exit
+ trap stop_system SIGHUP
+ echo "Successful ${CMD}."
+ else
+ # failed start, do stop
+ stop_system
+ echo "Failed ${CMD}."
fi
- # stop system on terminal exit
- trap stop_system SIGHUP
;;
stop )
stop_system
trap '' SIGHUP
+ echo "Successful ${CMD}."
;;
esac
-echo "Successful ${CMD}."