Skip to content

Instantly share code, notes, and snippets.

@gabrtv
Created November 6, 2011 00:36
Show Gist options
  • Save gabrtv/1342256 to your computer and use it in GitHub Desktop.
Save gabrtv/1342256 to your computer and use it in GitHub Desktop.
Gabrtv's Node.js Build Script
#!/bin/sh -e
# bootstrap application repository
cat > /tmp/bootstrap-app <<EOF
#!/bin/sh -e
git clone https://github.com/gabrtv/nodejs-sandbox.git app
cd app
npm install
EOF
chmod +x /tmp/bootstrap-app
su -l ubuntu -c /tmp/bootstrap-app
# install upstart daemon
cat > /etc/init/nodejs.conf <<EOF
#!upstart
description "node.js server"
author "OpDemand"
start on startup
stop on shutdown
script
export HOME="/home/ubuntu"
exec sudo -u ubuntu node /home/ubuntu/app/app.js 2>&1 >> /var/log/node.log
end script
EOF
# start the daemon
start nodejs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment