forked from blittle/jstesting
-
Notifications
You must be signed in to change notification settings - Fork 0
/
phantomServer.sh
49 lines (33 loc) · 1.43 KB
/
phantomServer.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/bash
ROOTDIR="."
JSTD_VERSION=1.3.4.b
COMMAND=$1
command -v phantomjs >/dev/null 2>&1 || { echo "Can't find phantomjs, please make sure it's on your PATH." >&2; exit 1; }
if [ ! -f "$ROOTDIR/jars/jsTestDriver.jar" ]; then
echo "Cannot find jars/jsTestDriver.jar"
fi
if [ ! -f "$ROOTDIR/jars/coverage.jar" ]; then
echo "Cannot find jars/coverage.jar"
fi
if [ ! -f "$ROOTDIR/jsTestDriver.conf" ]; then
echo "Cannot find jsTestDriver.conf"
fi
if [[ $COMMAND == "start" ]]; then
echo "Starting JSTD Server"
nohup java -jar $ROOTDIR/jars/jsTestDriver.jar --verbose --captureConsole --config jsTestDriver.conf --port 9876 > $ROOTDIR/testOutputDir/jstd.out 2> $ROOTDIR/testOutputDir/jstd.err < /dev/null &
echo $! > $ROOTDIR/testOutputDir/jstd.pid
echo "Starting PhantomJS"
wait 2
nohup phantomjs phantomjs-jstd.js > $ROOTDIR/testOutputDir/phantomjs.out 2> $ROOTDIR/testOutputDir/phantomjs.err < /dev/null &
echo $! > $ROOTDIR/testOutputDir/phantomjs.pid
fi
if [[ $COMMAND == "stop" ]]; then
echo "Killing JSTD Server"
PID=`cat $ROOTDIR/testOutputDir/jstd.pid`
kill $PID
rm -f $ROOTDIR/testOutputDir/jstd.out $ROOTDIR/testOutputDir/jstd.err $ROOTDIR/testOutputDir/jstd.pid
echo "Killing PhantomJS"
PID=`cat $ROOTDIR/testOutputDir/phantomjs.pid`
kill $PID
rm -f $ROOTDIR/testOutputDir/phantomjs.out $ROOTDIR/testOutputDir/phantomjs.err $ROOTDIR/testOutputDir/phantomjs.pid
fi