Skip to content

Instantly share code, notes, and snippets.

@amcginlay
Last active October 15, 2019 17:20
Show Gist options
  • Save amcginlay/6f02a509c2c9526793a25f4f49e382f7 to your computer and use it in GitHub Desktop.
Save amcginlay/6f02a509c2c9526793a25f4f49e382f7 to your computer and use it in GitHub Desktop.
nodejs server user data - example request: curl localhost/?workload=1000
#!/bin/bash
#############
# 1. Copy this script into EC2 User Data
# 2. Enable Cloudwatch detailed monitoring
# Usage: "curl localhost:80/?workload=1000"
#############
yum update -y
curl --silent --location https://rpm.nodesource.com/setup_10.x | bash -
yum -y install nodejs git
git clone https://github.com/amcginlay/nodejs-server.git /usr/local/bin/nodejs-server/
# NOTE the server will not survive a reboot.
PORT=80 node /usr/local/bin/nodejs-server/app.js > /var/log/nodejs-server-out.log
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment