Skip to content

Instantly share code, notes, and snippets.

@eladb
Created June 23, 2012 23:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eladb/2980597 to your computer and use it in GitHub Desktop.
Save eladb/2980597 to your computer and use it in GitHub Desktop.
mylittlepaas - ec2 user data
#!/bin/bash
# install node and friends
apt-add-repository -y ppa:chris-lea/node.js
apt-get update
apt-get install -y python-software-properties nodejs npm git make g++
# install girror (https://github.com/eladb/node-girror)
npm install -g girror
# create /etc/init/paas.conf
echo 'start on runlevel [2345]
stop on runlevel [06]
respawn
pre-start script
exec >> /var/log/paas.log 2>&1
REPO=https://github.com/eladb/mylittlepaas
mkdir -p /var/log
mkdir -p /var/www
echo "Fetching app from $REPO"
girror $REPO /var/www
if [ -f /var/www/package.json ]; then
echo "Installing npm modules"
cd /var/www
npm install
fi
end script
post-stop script
exec >> /var/log/paas.log 2>&1
echo "stopped"
end script
script
exec >> /var/log/paas.log 2>&1
export NODE_ENV=production
export port=80
echo "Starting app.js on port 80"
cd /var/www
node app.js
end script' > /etc/init/paas.conf
# start it
start paas
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment