diff options
author | Alexandru DAMIAN <alexandru.damian@intel.com> | 2014-06-03 16:26:15 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2014-06-06 10:32:54 +0100 |
commit | b610aaee9d4a1ee6671f74fbb5902ca48b09ad4a (patch) | |
tree | 933b4989489bc5f4808d7e853d887cc55ba506c0 /bitbake/bin | |
parent | 05cf6fe0ff0932801e20a53e716b030f553bd9d5 (diff) | |
download | poky-b610aaee9d4a1ee6671f74fbb5902ca48b09ad4a.tar.gz |
bitbake: toaster: startup script standalone mode
The toaster starter script was designed to be sourced in
a build environment and set up the build recording environment
to be used in an interactive mode.
For the standalone web server mode, we modify the toaster
script to be run directly from the checked-out sources,
without a build environment set up, and run the web server
alone. In the standalone mode, the build environemnts and
all build activities are controled through the web interface.
(Bitbake rev: c1db4ccf27bedcbab2f03e7539fdb11b042c4fb9)
Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/bin')
-rwxr-xr-x | bitbake/bin/toaster | 52 |
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 | ||
39 | function webserverStartAll() | 47 | function 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 | 122 | BBBASEDIR=`dirname ${BASH_SOURCE}`/.. |
123 | RUNNING=0 | ||
107 | 124 | ||
108 | if [ -z "$ZSH_NAME" ] && [ `basename \"$0\"` = `basename \"$BASH_SOURCE\"` ]; then | 125 | if [ -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 |
111 | fi | 151 | fi |
112 | 152 | ||
153 | # We make sure we're running in the current shell and in a good environment | ||
113 | if [ -z "$BUILDDIR" ] || [ -z `which bitbake` ]; then | 154 | if [ -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 |
116 | fi | 157 | fi |
117 | 158 | ||
118 | BBBASEDIR=`dirname ${BASH_SOURCE}`/.. | ||
119 | 159 | ||
120 | 160 | ||
121 | # Verify prerequisites | 161 | # Verify prerequisites |