diff options
| -rwxr-xr-x | bitbake/bin/toaster | 67 |
1 files changed, 6 insertions, 61 deletions
diff --git a/bitbake/bin/toaster b/bitbake/bin/toaster index d409554d13..6a85ae255c 100755 --- a/bitbake/bin/toaster +++ b/bitbake/bin/toaster | |||
| @@ -17,7 +17,7 @@ | |||
| 17 | # You should have received a copy of the GNU General Public License | 17 | # You should have received a copy of the GNU General Public License |
| 18 | # along with this program. If not, see http://www.gnu.org/licenses/. | 18 | # along with this program. If not, see http://www.gnu.org/licenses/. |
| 19 | 19 | ||
| 20 | # Usage: source toaster [start|stop|restart-bitbake] | 20 | # Usage: source toaster [start|stop] |
| 21 | # [webport=<port>] [noui] [noweb] | 21 | # [webport=<port>] [noui] [noweb] |
| 22 | 22 | ||
| 23 | # Helper function to kill a background toaster development server | 23 | # Helper function to kill a background toaster development server |
| @@ -95,7 +95,6 @@ stop_system() | |||
| 95 | kill `cat ${BUILDDIR}/.toasterui.pid` 2>/dev/null | 95 | kill `cat ${BUILDDIR}/.toasterui.pid` 2>/dev/null |
| 96 | rm ${BUILDDIR}/.toasterui.pid | 96 | rm ${BUILDDIR}/.toasterui.pid |
| 97 | fi | 97 | fi |
| 98 | stop_bitbake | ||
| 99 | webserverKillAll | 98 | webserverKillAll |
| 100 | # unset exported variables | 99 | # unset exported variables |
| 101 | unset DATABASE_URL | 100 | unset DATABASE_URL |
| @@ -106,31 +105,6 @@ stop_system() | |||
| 106 | INSTOPSYSTEM=0 | 105 | INSTOPSYSTEM=0 |
| 107 | } | 106 | } |
| 108 | 107 | ||
| 109 | start_bitbake() { | ||
| 110 | unset BBSERVER | ||
| 111 | bitbake --read conf/toaster.conf --server-only -t xmlrpc -B 0.0.0.0:0 | ||
| 112 | if [ $? -ne 0 ]; then | ||
| 113 | echo "Bitbake server start failed" | ||
| 114 | return 1 | ||
| 115 | fi | ||
| 116 | export BBSERVER=0.0.0.0:-1 | ||
| 117 | export DATABASE_URL=`$MANAGE get-dburl` | ||
| 118 | # we start the TOASTERUI only if not inhibited | ||
| 119 | if [ $NOTOASTERUI -eq 0 ]; then | ||
| 120 | bitbake --observe-only -u toasterui --remote-server=$BBSERVER -t xmlrpc \ | ||
| 121 | >>${BUILDDIR}/toaster_ui.log 2>&1 \ | ||
| 122 | & echo $! >${BUILDDIR}/.toasterui.pid | ||
| 123 | fi | ||
| 124 | return 0 | ||
| 125 | } | ||
| 126 | |||
| 127 | stop_bitbake() { | ||
| 128 | BBSERVER=0.0.0.0:-1 bitbake -m | ||
| 129 | unset BBSERVER | ||
| 130 | # force stop any misbehaving bitbake server | ||
| 131 | lsof -t bitbake.lock | awk '{print $2}' | grep "[0-9]\+" | xargs -n1 -r kill | ||
| 132 | } | ||
| 133 | |||
| 134 | verify_prereq() { | 108 | verify_prereq() { |
| 135 | # Verify Django version | 109 | # Verify Django version |
| 136 | reqfile=$(python -c "import os; print os.path.realpath('$BBBASEDIR/toaster-requirements.txt')") | 110 | reqfile=$(python -c "import os; print os.path.realpath('$BBBASEDIR/toaster-requirements.txt')") |
| @@ -229,15 +203,6 @@ if [ `basename \"$0\"` = `basename \"${TOASTER}\"` ]; then | |||
| 229 | return 1 | 203 | return 1 |
| 230 | fi | 204 | fi |
| 231 | 205 | ||
| 232 | if [ "$1" = 'restart-bitbake' ] ; then | ||
| 233 | stop_bitbake | ||
| 234 | sleep 1 | ||
| 235 | start_bitbake | ||
| 236 | rc=$? | ||
| 237 | sleep 3 | ||
| 238 | return $rc | ||
| 239 | fi | ||
| 240 | |||
| 241 | verify_prereq || return 1 | 206 | verify_prereq || return 1 |
| 242 | 207 | ||
| 243 | # We make sure we're running in the current shell and in a good environment | 208 | # We make sure we're running in the current shell and in a good environment |
| @@ -281,16 +246,6 @@ case $CMD in | |||
| 281 | $MANAGE checksocket "0.0.0.0:$WEB_PORT" || return 1 | 246 | $MANAGE checksocket "0.0.0.0:$WEB_PORT" || return 1 |
| 282 | fi | 247 | fi |
| 283 | 248 | ||
| 284 | # Make sure it's safe to start by checking bitbake lock | ||
| 285 | if [ -e $BUILDDIR/bitbake.lock ]; then | ||
| 286 | python -c "import fcntl; fcntl.flock(open(\"$BUILDDIR/bitbake.lock\"), fcntl.LOCK_EX|fcntl.LOCK_NB)" 2>/dev/null | ||
| 287 | if [ $? -ne 0 ] ; then | ||
| 288 | echo "Error: bitbake lock state error. File locks show that the system is on." 1>&2 | ||
| 289 | echo "Please wait for the current build to finish, stop and then start the system again." 1>&2 | ||
| 290 | return 3 | ||
| 291 | fi | ||
| 292 | fi | ||
| 293 | |||
| 294 | # kill Toaster web server if it's alive | 249 | # kill Toaster web server if it's alive |
| 295 | if [ -e $BUILDDIR/.toastermain.pid ] && kill -0 `cat $BUILDDIR/.toastermain.pid`; then | 250 | if [ -e $BUILDDIR/.toastermain.pid ] && kill -0 `cat $BUILDDIR/.toastermain.pid`; then |
| 296 | echo "Warning: bitbake appears to be dead, but the Toaster web server is running." 1>&2 | 251 | echo "Warning: bitbake appears to be dead, but the Toaster web server is running." 1>&2 |
| @@ -308,22 +263,12 @@ case $CMD in | |||
| 308 | echo "Failed ${CMD}." | 263 | echo "Failed ${CMD}." |
| 309 | return 4 | 264 | return 4 |
| 310 | fi | 265 | fi |
| 311 | start_bitbake | 266 | export DATABASE_URL=`$MANAGE get-dburl` |
| 312 | if [ $? -eq 0 ]; then | 267 | $MANAGE runbuilds & echo $! >${BUILDDIR}/.runbuilds.pid |
| 313 | $MANAGE runbuilds & echo $! >${BUILDDIR}/.runbuilds.pid | 268 | # set fail safe stop system on terminal exit |
| 314 | # set fail safe stop system on terminal exit | ||
| 315 | trap stop_system SIGHUP | ||
| 316 | echo "Successful ${CMD}." | ||
| 317 | return 0 | ||
| 318 | else | ||
| 319 | # failed start, do stop | ||
| 320 | stop_system | ||
| 321 | echo "Failed ${CMD}." | ||
| 322 | return 1 | ||
| 323 | fi | ||
| 324 | # stop system on terminal exit | ||
| 325 | set -o monitor | ||
| 326 | trap stop_system SIGHUP | 269 | trap stop_system SIGHUP |
| 270 | echo "Successful ${CMD}." | ||
| 271 | return 0 | ||
| 327 | ;; | 272 | ;; |
| 328 | stop ) | 273 | stop ) |
| 329 | stop_system | 274 | stop_system |
