summaryrefslogtreecommitdiffstats
path: root/bitbake
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake')
-rwxr-xr-xbitbake/bin/toaster52
1 files changed, 46 insertions, 6 deletions
diff --git a/bitbake/bin/toaster b/bitbake/bin/toaster
index f81e6672fb..80bda6d67c 100755
--- a/bitbake/bin/toaster
+++ b/bitbake/bin/toaster
@@ -16,9 +16,15 @@
16# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 17
18 18
19# This script enables toaster event logging and 19# This script can be run in two modes.
20# starts bitbake resident server 20
21# use as: source toaster [start|stop] 21# When used with "source", from a build directory,
22# it enables toaster event logging and starts the bitbake resident server.
23# use as: source toaster [start|stop] [noweb] [noui]
24
25# When it is called as a stand-alone script, it starts just the
26# web server, and the building shall be done through the web interface.
27# As script, it will not return to the command prompt. Stop with Ctrl-C.
22 28
23# Helper function to kill a background toaster development server 29# Helper function to kill a background toaster development server
24 30
@@ -30,6 +36,8 @@ function webserverKillAll()
30 while kill -0 $(< ${pidfile}) 2>/dev/null; do 36 while kill -0 $(< ${pidfile}) 2>/dev/null; do
31 kill -SIGTERM -$(< ${pidfile}) 2>/dev/null 37 kill -SIGTERM -$(< ${pidfile}) 2>/dev/null
32 sleep 1; 38 sleep 1;
39 # Kill processes if they are still running - may happen in interactive shells
40 ps fux | grep "python.*manage.py" | awk '{print $2}' | xargs kill
33 done; 41 done;
34 rm ${pidfile} 42 rm ${pidfile}
35 fi 43 fi
@@ -38,6 +46,12 @@ function webserverKillAll()
38 46
39function webserverStartAll() 47function webserverStartAll()
40{ 48{
49 # do not start if toastermain points to a valid process
50 if ! cat "${BUILDDIR}/.toastermain.pid" 2>/dev/null | xargs -I{} kill -0 {} ; then
51 retval=1
52 rm "${BUILDDIR}/.toastermain.pid"
53 fi
54
41 retval=0 55 retval=0
42 python $BBBASEDIR/lib/toaster/manage.py syncdb || retval=1 56 python $BBBASEDIR/lib/toaster/manage.py syncdb || retval=1
43 python $BBBASEDIR/lib/toaster/manage.py migrate orm || retval=2 57 python $BBBASEDIR/lib/toaster/manage.py migrate orm || retval=2
@@ -49,6 +63,8 @@ function webserverStartAll()
49 retval=0 63 retval=0
50 python $BBBASEDIR/lib/toaster/manage.py migrate orm || retval=1 64 python $BBBASEDIR/lib/toaster/manage.py migrate orm || retval=1
51 fi 65 fi
66 python $BBBASEDIR/lib/toaster/manage.py migrate bldcontrol || retval=1
67
52 if [ $retval -eq 0 ]; then 68 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 69 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 70 sleep 1
@@ -103,19 +119,43 @@ function notify_chldexit() {
103} 119}
104 120
105 121
106# We make sure we're running in the current shell and in a good environment 122BBBASEDIR=`dirname ${BASH_SOURCE}`/..
123RUNNING=0
107 124
108if [ -z "$ZSH_NAME" ] && [ `basename \"$0\"` = `basename \"$BASH_SOURCE\"` ]; then 125if [ -z "$ZSH_NAME" ] && [ `basename \"$0\"` = `basename \"$BASH_SOURCE\"` ]; then
109 echo "Error: This script needs to be sourced. Please run as 'source toaster [start|stop]'" 1>&2; 126 # We are called as standalone. We refuse to run in a build environment - we need the interactive mode for that.
127 # Start just the web server, point the web browser to the interface, and start any Django services.
128
129 if [ -n "$BUILDDIR" ]; then
130 echo "Error: build/ directory detected. Standalone Toaster will not start in a build environment." 1>&2;
131 return 1;
132 fi
133
134 # Define a fake builddir where only the pid files are actually created. No real builds will take place here.
135 BUILDDIR=/tmp
136 RUNNING=1
137 function trap_ctrlc() {
138 echo "** Stopping system"
139 webserverKillAll
140 RUNNING=0
141 }
142 webserverStartAll || exit 1
143 xdg-open http://0.0.0.0:8000/ >/dev/null 2>&1 &
144 trap trap_ctrlc SIGINT
145 echo "Running. Stop with Ctrl-C"
146 while [ $RUNNING -gt 0 ]; do
147 wait;
148 done
149 echo "**** Exit"
110 exit 1 150 exit 1
111fi 151fi
112 152
153# We make sure we're running in the current shell and in a good environment
113if [ -z "$BUILDDIR" ] || [ -z `which bitbake` ]; then 154if [ -z "$BUILDDIR" ] || [ -z `which bitbake` ]; then
114 echo "Error: Build environment is not setup or bitbake is not in path." 1>&2; 155 echo "Error: Build environment is not setup or bitbake is not in path." 1>&2;
115 return 2 156 return 2
116fi 157fi
117 158
118BBBASEDIR=`dirname ${BASH_SOURCE}`/..
119 159
120 160
121# Verify prerequisites 161# Verify prerequisites