mirror of
https://git.yoctoproject.org/poky
synced 2026-05-31 00:39:46 +00:00
bitbake: toaster: clean exit on bb server shutdown
This patch adds the capability to have the Toaster UI detect when the Bitbake server exited and cleanly trigger a clean shutdown of the system through the toaster starting script. (Bitbake rev: a9cfa3eacfc99550e1ad3f8bb61b2a0bc9b44332) Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
1913a1751d
commit
70f1a3db5e
+26
-2
@@ -68,11 +68,16 @@ function addtoConfiguration()
|
|||||||
echo $1 >> ${BUILDDIR}/conf/$2
|
echo $1 >> ${BUILDDIR}/conf/$2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
INSTOPSYSTEM=0
|
||||||
|
|
||||||
# define the stop command
|
# define the stop command
|
||||||
function stop_system()
|
function stop_system()
|
||||||
{
|
{
|
||||||
|
# prevent reentry
|
||||||
|
if [ $INSTOPSYSTEM == 1 ]; then return; fi
|
||||||
|
INSTOPSYSTEM=1
|
||||||
if [ -f ${BUILDDIR}/.toasterui.pid ]; then
|
if [ -f ${BUILDDIR}/.toasterui.pid ]; then
|
||||||
kill $(< ${BUILDDIR}/.toasterui.pid )
|
kill $(< ${BUILDDIR}/.toasterui.pid ) 2>/dev/null
|
||||||
rm ${BUILDDIR}/.toasterui.pid
|
rm ${BUILDDIR}/.toasterui.pid
|
||||||
fi
|
fi
|
||||||
BBSERVER=localhost:8200 bitbake -m
|
BBSERVER=localhost:8200 bitbake -m
|
||||||
@@ -80,8 +85,24 @@ function stop_system()
|
|||||||
webserverKillAll
|
webserverKillAll
|
||||||
# force stop any misbehaving bitbake server
|
# force stop any misbehaving bitbake server
|
||||||
lsof bitbake.lock | awk '{print $2}' | grep "[0-9]\+" | xargs -n1 -r kill
|
lsof bitbake.lock | awk '{print $2}' | grep "[0-9]\+" | xargs -n1 -r kill
|
||||||
|
trap - SIGHUP
|
||||||
|
trap - SIGCHLD
|
||||||
|
INSTOPSYSTEM=0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function check_pidbyfile() {
|
||||||
|
[ -e $1 ] && kill -0 $(< $1) 2>/dev/null
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function notify_chldexit() {
|
||||||
|
if [ $NOTOASTERUI == 0 ]; then
|
||||||
|
check_pidbyfile ${BUILDDIR}/.toasterui.pid && return
|
||||||
|
stop_system
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
# We make sure we're running in the current shell and in a good environment
|
# We make sure we're running in the current shell and in a good environment
|
||||||
|
|
||||||
if [ -z "$ZSH_NAME" ] && [ `basename \"$0\"` = `basename \"$BASH_SOURCE\"` ]; then
|
if [ -z "$ZSH_NAME" ] && [ `basename \"$0\"` = `basename \"$BASH_SOURCE\"` ]; then
|
||||||
@@ -179,10 +200,13 @@ case $CMD in
|
|||||||
stop_system
|
stop_system
|
||||||
echo "Failed ${CMD}."
|
echo "Failed ${CMD}."
|
||||||
fi
|
fi
|
||||||
|
# stop system on terminal exit
|
||||||
|
set -o monitor
|
||||||
|
trap stop_system SIGHUP
|
||||||
|
trap notify_chldexit SIGCHLD
|
||||||
;;
|
;;
|
||||||
stop )
|
stop )
|
||||||
stop_system
|
stop_system
|
||||||
trap '' SIGHUP
|
|
||||||
echo "Successful ${CMD}."
|
echo "Successful ${CMD}."
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|||||||
@@ -249,6 +249,10 @@ def main(server, eventHandler, params ):
|
|||||||
buildinfohelper.store_license_manifest_path(event)
|
buildinfohelper.store_license_manifest_path(event)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
if isinstance(event, bb.cooker.CookerExit):
|
||||||
|
# exit when the server exits
|
||||||
|
break
|
||||||
|
|
||||||
# ignore
|
# ignore
|
||||||
if isinstance(event, (bb.event.BuildBase,
|
if isinstance(event, (bb.event.BuildBase,
|
||||||
bb.event.StampUpdate,
|
bb.event.StampUpdate,
|
||||||
@@ -258,8 +262,7 @@ def main(server, eventHandler, params ):
|
|||||||
bb.event.OperationProgress,
|
bb.event.OperationProgress,
|
||||||
bb.command.CommandFailed,
|
bb.command.CommandFailed,
|
||||||
bb.command.CommandExit,
|
bb.command.CommandExit,
|
||||||
bb.command.CommandCompleted,
|
bb.command.CommandCompleted)):
|
||||||
bb.cooker.CookerExit)):
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if isinstance(event, bb.event.DepTreeGenerated):
|
if isinstance(event, bb.event.DepTreeGenerated):
|
||||||
|
|||||||
Reference in New Issue
Block a user