Skip to content

Commit

Permalink
cli-test: Use node instead of Python.
Browse files Browse the repository at this point in the history
It's guaranteed to be there, and works better!
  • Loading branch information
glasser committed Jan 3, 2013
1 parent bc9e699 commit fb24d39
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions admin/cli-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
cd `dirname $0`
METEOR=`pwd`/../meteor

if [ -z "$NODE" ]; then
NODE=`pwd`/node.sh
fi

#If this ever takes more options, use getopt
if [ "$1" == "--global" ]; then
METEOR=meteor
Expand Down Expand Up @@ -125,20 +129,18 @@ sleep 2 # need to make sure these kills take effect

echo "... mongo message"

# Use Python to listen on a port, so that Mongo fails to start up. (We used to
# use nc here, but the way you specify listener ports to nc varies between
# platforms. Bleah.)
python -c 'from socket import *; s = socket(); s.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1); s.bind(("127.0.0.1", '$PORT'+2)); s.listen(1); s.accept()' &
PYTHON_PID=$!
# Run a server on the same port as mongod, so that mongod fails to start up. Rig
# it so that a single connection will cause it to exit.
$NODE -e 'require("net").createServer(function(){process.exit(0)}).listen('$PORT'+2, "127.0.0.1")' &

sleep 1

$METEOR -p $PORT > error.txt || true

grep 'port was closed' error.txt > /dev/null

kill -9 $PYTHON_PID > /dev/null

# Kill the server by connecting to it.
$NODE -e 'require("net").connect({host:"127.0.0.1",port:'$PORT'+2},function(){process.exit(0);})'

echo "... settings"

Expand Down

0 comments on commit fb24d39

Please sign in to comment.