aboutsummaryrefslogtreecommitdiff
path: root/cbt
diff options
context:
space:
mode:
authorChristopher Vogt <oss.nsp@cvogt.org>2016-03-06 22:12:05 -0500
committerChristopher Vogt <oss.nsp@cvogt.org>2016-03-06 22:25:19 -0500
commit1f5242bac286d88a7ff9026a785653a3335fc999 (patch)
tree00c2d5aca96ea156bc6e3c9d4fabc13dd1adae1e /cbt
parentd5b43bc0eaedfba1c5be6bff1673b426af030c81 (diff)
downloadcbt-1f5242bac286d88a7ff9026a785653a3335fc999.tar.gz
cbt-1f5242bac286d88a7ff9026a785653a3335fc999.tar.bz2
cbt-1f5242bac286d88a7ff9026a785653a3335fc999.zip
refactored and improved nailgun code in bash script. Should be easier to debug now. Doesn't wait endlessly.
Diffstat (limited to 'cbt')
-rwxr-xr-xcbt61
1 files changed, 44 insertions, 17 deletions
diff --git a/cbt b/cbt
index f66d2b8..d4d51f3 100755
--- a/cbt
+++ b/cbt
@@ -85,9 +85,29 @@ export TARGET=target/scala-2.11/classes/
mkdir -p $NAILGUN$TARGET
mkdir -p $STAGE1$TARGET
+nailgun_out=$NAILGUN/target/nailgun.stdout.log
+nailgun_err=$NAILGUN/target/nailgun.strerr.log
+foo(){
+ while test $# -gt 0; do
+ case "$1" in
+ "-Dlog=nailgun")
+ nailgun_out=/dev/stderr
+ nailgun_err=/dev/stderr
+ ;;
+ "-Dlog=all")
+ nailgun_out=/dev/stderr
+ nailgun_err=/dev/stderr
+ ;;
+ esac
+ shift
+ done
+}
+
+foo $@
+
if [ "$1" = "kill" ]; then
echo "Stopping nailgun" 1>&2
- $NG ng-stop >> $NAILGUN/target/nailgun.stdout.log 2>> $NAILGUN/target/nailgun.stderr.log &
+ $NG ng-stop >> $nailgun_out 2>> $nailgun_err &
exit 1
fi
@@ -104,10 +124,15 @@ else
echo "(Note: nc not found. It will make slightly startup faster.)" 1>&2
fi
-if [ $nc_installed -eq 0 ] || [ ! $server_up -eq 0 ]; then
+use_nailgun=0
+if [ $nailgun_installed -eq 1 ] || [ "$1" = "publishSigned" ] || [ "$2" = "publishSigned" ] || [ "$1" = "direct" ] || [ "$2" = "direct" ]; then
+ use_nailgun=1
+fi
+
+if [ $use_nailgun -eq 0 ] && [ ! $server_up -eq 0 ]; then
log "Starting up nailgun server." $*
# try to start nailgun-server, just in case it's not up
- ng-server 127.0.0.1:$NAILGUN_PORT >> $NAILGUN/target/nailgun.stdout.log 2>> $NAILGUN/target/nailgun.stderr.log &
+ ng-server 127.0.0.1:$NAILGUN_PORT >> $nailgun_out 2>> $nailgun_err &
fi
log "Downloading Scala jars if necessary..." $*
@@ -135,12 +160,12 @@ stage1 () {
echo "Compiling cbt/nailgun_launcher" 1>&2
javac -Xlint:deprecation -d $NAILGUN$TARGET `ls $NAILGUN*.java`
compiles=$?
- if [ $compiles -ne 0 ]; then exit 1; fi
- if [ $nailgun_installed -eq 0 ]; then
+ if [ $compiles -ne 0 ]; then break; fi
+ if [ $use_nailgun -eq 0 ]; then
echo "Stopping nailgun" 1>&2
- $NG ng-stop >> $NAILGUN/target/nailgun.stdout.log 2>> $NAILGUN/target/nailgun.stderr.log &
+ $NG ng-stop >> $nailgun_out 2>> $nailgun_err &
echo "Restarting nailgun" 1>&2
- ng-server 127.0.0.1:$NAILGUN_PORT >> $NAILGUN/target/nailgun.stdout.log 2>> $NAILGUN/target/nailgun.stderr.log &
+ ng-server 127.0.0.1:$NAILGUN_PORT >> $nailgun_out 2>> $nailgun_err &
fi
fi
@@ -157,7 +182,7 @@ stage1 () {
rm $STAGE1$TARGET/cbt/*.class 2>/dev/null
$SCALAC -cp $NAILGUN$TARGET -d $STAGE1$TARGET `ls $STAGE1/*.scala`
compiles2=$?
- if [ $compiles2 -ne 0 ]; then exit 1; fi
+ if [ $compiles2 -ne 0 ]; then break; fi
fi
log "run CBT and loop if desired. This allows recompiling CBT itself as part of compile looping." $*
@@ -168,27 +193,29 @@ stage1 () {
fi
CP=$STAGE1$TARGET:$SCALA_CLASSPATH
- if [ $nailgun_installed -eq 1 ] || [ "$1" = "publishSigned" ] || [ "$2" = "publishSigned" ] || [ "$1" = "direct" ] || [ "$2" = "direct" ]
+ if [ $use_nailgun -eq 1 ]
then
log "Running JVM directly" $*
# -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=localhost:5005
java -cp $NAILGUN$TARGET cbt.NailgunLauncher $mainClass $CP "$CWD" $*
else
log "Running via nailgun." $*
- while true; do
+ for i in 0 1 2 3 4 5 6 7 8 9; do
log "Adding classpath." $*
- $NG ng-cp $NAILGUN$TARGET >> $NAILGUN/target/nailgun.stdout.log 2>> $NAILGUN/target/nailgun.stderr.log
+ $NG ng-cp $NAILGUN$TARGET >> $nailgun_out 2>> $nailgun_err
log "Checking if nailgun is up yet." $*
- $NG cbt.NailgunLauncher cbt.CheckAlive $CP "$CWD" $* >> $NAILGUN/target/nailgun.stdout.log 2>> $NAILGUN/target/nailgun.stderr.log
+ $NG cbt.NailgunLauncher cbt.CheckAlive $CP "$CWD" $* >> $nailgun_out 2>> $nailgun_err
alive=$?
- if [[ $alive -eq 131 ]]; then
+ if [ $alive -eq 131 ]; then
echo "Nailgun call failed. Try 'cbt kill' and check the error log cbt/nailgun_launcher/target/nailgun.stderr.log" 1>&2
- elif [[ $alive -eq 33 ]]; then
+ elif [ $alive -eq 33 ]; then
break
else
- log "Nope. Sleeping for 1 second" $*
- echo "Waiting for nailgun to start..." 1>&2
- sleep 1
+ log "Nope. Sleeping for 0.5 seconds" $*
+ if [ "$i" -gt "1" ]; then
+ echo "Waiting for nailgun to start... (For problems try -Dlog=nailgun or check logs in cbt/nailgun_launcher/target/*.log)" 1>&2
+ fi
+ sleep 0.5
fi
done
log "Running $mainClass via Nailgun." $*