summaryrefslogtreecommitdiffstats
path: root/bitbake
diff options
context:
space:
mode:
authorAlexandru DAMIAN <alexandru.damian@intel.com>2014-01-09 15:11:59 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2014-03-25 11:17:34 +0000
commit70f1a3db5e102cff658e51007e0cac5207f197bb (patch)
treeea3db15a1dd9ab0a7d75b0c30c3608d51e0e805e /bitbake
parent1913a1751d50c6e6011faea57999a4d342963de9 (diff)
downloadpoky-70f1a3db5e102cff658e51007e0cac5207f197bb.tar.gz
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>
Diffstat (limited to 'bitbake')
-rwxr-xr-xbitbake/bin/toaster28
-rw-r--r--bitbake/lib/bb/ui/toasterui.py7
2 files changed, 31 insertions, 4 deletions
diff --git a/bitbake/bin/toaster b/bitbake/bin/toaster
index 9c0a15ff67..b27f7c28bb 100755
--- a/bitbake/bin/toaster
+++ b/bitbake/bin/toaster
@@ -68,11 +68,16 @@ function addtoConfiguration()
68 echo $1 >> ${BUILDDIR}/conf/$2 68 echo $1 >> ${BUILDDIR}/conf/$2
69} 69}
70 70
71INSTOPSYSTEM=0
72
71# define the stop command 73# define the stop command
72function stop_system() 74function stop_system()
73{ 75{
76 # prevent reentry
77 if [ $INSTOPSYSTEM == 1 ]; then return; fi
78 INSTOPSYSTEM=1
74 if [ -f ${BUILDDIR}/.toasterui.pid ]; then 79 if [ -f ${BUILDDIR}/.toasterui.pid ]; then
75 kill $(< ${BUILDDIR}/.toasterui.pid ) 80 kill $(< ${BUILDDIR}/.toasterui.pid ) 2>/dev/null
76 rm ${BUILDDIR}/.toasterui.pid 81 rm ${BUILDDIR}/.toasterui.pid
77 fi 82 fi
78 BBSERVER=localhost:8200 bitbake -m 83 BBSERVER=localhost:8200 bitbake -m
@@ -80,8 +85,24 @@ function stop_system()
80 webserverKillAll 85 webserverKillAll
81 # force stop any misbehaving bitbake server 86 # force stop any misbehaving bitbake server
82 lsof bitbake.lock | awk '{print $2}' | grep "[0-9]\+" | xargs -n1 -r kill 87 lsof bitbake.lock | awk '{print $2}' | grep "[0-9]\+" | xargs -n1 -r kill
88 trap - SIGHUP
89 trap - SIGCHLD
90 INSTOPSYSTEM=0
91}
92
93function check_pidbyfile() {
94 [ -e $1 ] && kill -0 $(< $1) 2>/dev/null
83} 95}
84 96
97
98function notify_chldexit() {
99 if [ $NOTOASTERUI == 0 ]; then
100 check_pidbyfile ${BUILDDIR}/.toasterui.pid && return
101 stop_system
102 fi
103}
104
105
85# We make sure we're running in the current shell and in a good environment 106# We make sure we're running in the current shell and in a good environment
86 107
87if [ -z "$ZSH_NAME" ] && [ `basename \"$0\"` = `basename \"$BASH_SOURCE\"` ]; then 108if [ -z "$ZSH_NAME" ] && [ `basename \"$0\"` = `basename \"$BASH_SOURCE\"` ]; then
@@ -179,10 +200,13 @@ case $CMD in
179 stop_system 200 stop_system
180 echo "Failed ${CMD}." 201 echo "Failed ${CMD}."
181 fi 202 fi
203 # stop system on terminal exit
204 set -o monitor
205 trap stop_system SIGHUP
206 trap notify_chldexit SIGCHLD
182 ;; 207 ;;
183 stop ) 208 stop )
184 stop_system 209 stop_system
185 trap '' SIGHUP
186 echo "Successful ${CMD}." 210 echo "Successful ${CMD}."
187 ;; 211 ;;
188esac 212esac
diff --git a/bitbake/lib/bb/ui/toasterui.py b/bitbake/lib/bb/ui/toasterui.py
index 453eaf9485..37d6b1a0cf 100644
--- a/bitbake/lib/bb/ui/toasterui.py
+++ b/bitbake/lib/bb/ui/toasterui.py
@@ -249,6 +249,10 @@ def main(server, eventHandler, params ):
249 buildinfohelper.store_license_manifest_path(event) 249 buildinfohelper.store_license_manifest_path(event)
250 continue 250 continue
251 251
252 if isinstance(event, bb.cooker.CookerExit):
253 # exit when the server exits
254 break
255
252 # ignore 256 # ignore
253 if isinstance(event, (bb.event.BuildBase, 257 if isinstance(event, (bb.event.BuildBase,
254 bb.event.StampUpdate, 258 bb.event.StampUpdate,
@@ -258,8 +262,7 @@ def main(server, eventHandler, params ):
258 bb.event.OperationProgress, 262 bb.event.OperationProgress,
259 bb.command.CommandFailed, 263 bb.command.CommandFailed,
260 bb.command.CommandExit, 264 bb.command.CommandExit,
261 bb.command.CommandCompleted, 265 bb.command.CommandCompleted)):
262 bb.cooker.CookerExit)):
263 continue 266 continue
264 267
265 if isinstance(event, bb.event.DepTreeGenerated): 268 if isinstance(event, bb.event.DepTreeGenerated):