summaryrefslogtreecommitdiffstats
path: root/bitbake
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:03:05 +0000
commit6c294f0a2ed6d0182bf85708a4fae240c260c0e5 (patch)
tree6f2fb33777219deabb8ffecec0c1737eb515205a /bitbake
parent18d486c58a55d91c56678d5355958d7a2c7fd1e9 (diff)
downloadpoky-6c294f0a2ed6d0182bf85708a4fae240c260c0e5.tar.gz
bitbake: 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. (Bitbake rev: f43d284e7ae752049711d8215a6020bee6966d45) 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/bitbake1
-rwxr-xr-xbitbake/bin/toaster45
2 files changed, 36 insertions, 10 deletions
diff --git a/bitbake/bin/bitbake b/bitbake/bin/bitbake
index d27fe849fb..cbfd2c97b6 100755
--- a/bitbake/bin/bitbake
+++ b/bitbake/bin/bitbake
@@ -343,6 +343,7 @@ def main():
343 server_connection.terminate() 343 server_connection.terminate()
344 else: 344 else:
345 print("server address: %s, server port: %s" % (server.serverImpl.host, server.serverImpl.port)) 345 print("server address: %s, server port: %s" % (server.serverImpl.host, server.serverImpl.port))
346 return 0
346 347
347 return 1 348 return 1
348 349
diff --git a/bitbake/bin/toaster b/bitbake/bin/toaster
index fc59fe5547..38e71acc2b 100755
--- a/bitbake/bin/toaster
+++ b/bitbake/bin/toaster
@@ -51,6 +51,11 @@ function webserverStartAll()
51 fi 51 fi
52 if [ $retval -eq 0 ]; then 52 if [ $retval -eq 0 ]; then
53 python $BBBASEDIR/lib/toaster/manage.py runserver 0.0.0.0:8000 </dev/null >${BUILDDIR}/toaster_web.log 2>&1 & echo $! >${BUILDDIR}/.toastermain.pid 53 python $BBBASEDIR/lib/toaster/manage.py runserver 0.0.0.0:8000 </dev/null >${BUILDDIR}/toaster_web.log 2>&1 & echo $! >${BUILDDIR}/.toastermain.pid
54 sleep 1
55 if ! cat "${BUILDDIR}/.toastermain.pid" | xargs -I{} kill -0 {} ; then
56 retval=1
57 rm "${BUILDDIR}/.toastermain.pid"
58 fi
54 fi 59 fi
55 return $retval 60 return $retval
56} 61}
@@ -120,9 +125,13 @@ else
120fi 125fi
121 126
122NOTOASTERUI=0 127NOTOASTERUI=0
123if [ "x$2" == "xnoui" ]; then 128for param in $*; do
124 NOTOASTERUI=1 129 case $param in
125fi 130 noui )
131 NOTOASTERUI=1
132 ;;
133 esac
134done
126 135
127echo "The system will $CMD." 136echo "The system will $CMD."
128 137
@@ -157,22 +166,38 @@ fi
157 166
158case $CMD in 167case $CMD in
159 start ) 168 start )
169 start_success=1
160 addtoConfiguration "INHERIT+=\"toaster buildhistory\"" toaster.conf 170 addtoConfiguration "INHERIT+=\"toaster buildhistory\"" toaster.conf
161 webserverStartAll || return 4 171 if ! webserverStartAll; then
172 echo "Failed ${CMD}."
173 return 4
174 fi
162 unset BBSERVER 175 unset BBSERVER
163 bitbake --postread conf/toaster.conf --server-only -t xmlrpc -B localhost:8200 176 bitbake --postread conf/toaster.conf --server-only -t xmlrpc -B localhost:8200
164 export BBSERVER=localhost:8200 177 if [ $? -ne 0 ]; then
165 if [ $NOTOASTERUI == 0 ]; then # we start the TOASTERUI only if not inhibited 178 start_success=0
166 bitbake --observe-only -u toasterui >${BUILDDIR}/toaster_ui.log 2>&1 & echo $! >${BUILDDIR}/.toasterui.pid 179 echo "Bitbake server start failed"
180 else
181 export BBSERVER=localhost:8200
182 if [ $NOTOASTERUI == 0 ]; then # we start the TOASTERUI only if not inhibited
183 bitbake --observe-only -u toasterui >${BUILDDIR}/toaster_ui.log 2>&1 & echo $! >${BUILDDIR}/.toasterui.pid
184 fi
185 fi
186 if [ $start_success -eq 1 ]; then
187 # set fail safe stop system on terminal exit
188 trap stop_system SIGHUP
189 echo "Successful ${CMD}."
190 else
191 # failed start, do stop
192 stop_system
193 echo "Failed ${CMD}."
167 fi 194 fi
168 # stop system on terminal exit
169 trap stop_system SIGHUP
170 ;; 195 ;;
171 stop ) 196 stop )
172 stop_system 197 stop_system
173 trap '' SIGHUP 198 trap '' SIGHUP
199 echo "Successful ${CMD}."
174 ;; 200 ;;
175esac 201esac
176 202
177echo "Successful ${CMD}."
178 203