committing my progress, but no working tests yet. stuck on bug where I can't curl the URL I get from the deploy transcript

This commit is contained in:
Jeff Lindsay
2013-06-10 21:26:31 -07:00
parent 06f2c8ff5e
commit 3e2989d954
6 changed files with 69 additions and 5 deletions

View File

@@ -0,0 +1 @@
web: bin/node web.js

View File

@@ -0,0 +1,11 @@
{
"name": "node-example",
"version": "0.0.1",
"dependencies": {
"express": "2.5.x"
},
"engines": {
"node": "0.8.x",
"npm": "1.1.x"
}
}

View File

@@ -0,0 +1,12 @@
var express = require('express');
var app = express.createServer(express.logger());
app.get('/', function(request, response) {
response.send('nodejs/express');
});
var port = process.env.PORT || 5000;
app.listen(port, function() {
console.log("Listening on " + port);
});

View File

@@ -1,12 +1,18 @@
#!/bin/bash
KEYNAME="$1"
indent() { sed "s/^/ /"; }
echo "-----> Booting EC2 instance..."
INSTANCE=$(ec2-run-instances -k $1 ami-c90277a0 2>/dev/null | awk '/^INSTANCE/ {print $2}')
start=$(ec2-run-instances -k $1 ami-f3d1bb9a 2>/dev/null)
if [[ $? > 0 ]]; then
echo "$start"
exit
fi
INSTANCE=$(echo "$start" | awk '/^INSTANCE/ {print $2}')
terminate() {
echo "-----> Terminating $INSTANCE..."
ec2-terminate-instances $INSTANCE &>/dev/null && echo " Shutting down"
}
#trap "terminate" EXIT
trap "terminate" EXIT
sleep 30
status=""
while [[ "$status" != "running" ]]; do
@@ -20,8 +26,7 @@ while [[ "$status" != "running" ]]; do
fi
done
PUBLIC_IP=$(echo "$info" | awk '{print $14}')
echo "-----> Waiting for SSH on instance..."
echo "-----> Waiting for SSH at $PUBLIC_IP..."
sleep 10
echo "-----> Connecting and running boostrap script..."
indent() { sed "s/^/ /"; }
cat ../bootstrap.sh | ssh -o "StrictHostKeyChecking=no" ubuntu@$PUBLIC_IP "HOSTNAME=$PUBLIC_IP sudo bash" 2>/dev/null | indent
cat ../bootstrap.sh | ssh -o "StrictHostKeyChecking=no" ubuntu@$PUBLIC_IP "HOSTNAME=$PUBLIC_IP sudo bash" 2>&1 | indent

14
tests/run_vagrant Executable file
View File

@@ -0,0 +1,14 @@
#!/bin/bash
SELF=`which $0`
VAGRANT_SSH_PORT=${$VAGRANT_SSH_PORT:-"2222"}
PUBLIC_KEY=${PUBLIC_KEY:-"~/.ssh/id_rsa.pub"}
indent() { sed "s/^/ /"; }
if [[ ! $(cat ~/.ssh/config 2>/dev/null | grep dokku.me) ]]; then
echo "-----> Configuring SSH to use $VAGRANT_SSH_PORT for dokku.me..."
touch ~/.ssh/config
echo "Host dokku.me" >> ~/.ssh/config
echo " Port $VAGRANT_SSH_PORT" >> ~/.ssh/config
fi
echo "-----> Ensuring Vagrant is running..."
cd "$(dirname $SELF)/.." && vagrant up | indent
cat $PUBLIC_KEY | ssh -o "StrictHostKeyChecking=no" -i ~/.vagrant.d/insecure_private_key vagrant@dokku.me "sudo gitreceive upload-key test"

21
tests/test_deploy Executable file
View File

@@ -0,0 +1,21 @@
#!/bin/bash
# set -e
SELF=`which $0`; APP="$1"; TARGET="$2"
TMP=$(mktemp -d -t $TARGET)
trap "rm -rf $TMP" EXIT
cp -r $(dirname $SELF)/$APP/* $TMP
cd $TMP
git init
git add .
git commit -m 'initial commit'
REPO="test-$RANDOM"
git remote add target git@$TARGET:$REPO
URL_FILE=$(mktemp -t url)
git push target master 2>&1 | while read line; do
echo "$line"
[[ $(echo "$line" | grep $TARGET | grep remote) ]] && echo "$line" | awk '{print $2}' > $URL_FILE
done
set -x
URL=$(<$URL_FILE)
curl -v "$URL:8080" # GAHAHHHHH WHY DOESNT THIS WORK
rm $URL_FILE