NodeJS will forever work on AWS EC2

I am trying to configure NodeJS on EC2.

I followed the official guide and it was successful on my local machine. However, compiling source code on EC2 requires endless completion (2 hours and counting). I assume this has something to do with the processor limit or timeout.

I am not familiar with Linux and makefiles. Is there any way around this? Thanks,

+7
source share
2 answers

I assume you are using a micro instance. Yes, it will take some time - micro-instances get a lot of CPU for a short time, and then become very closed if you use the processor for a while. Compilation node.js - processor intensity.

On the bright side, you only need to do this once. When finished, run AMI, and you can start as many servers with node.js as you want, as you wish.

+12
source

What distribution kit are you in? I am using ubuntu 10.04 LTS (ami-ad36fbc4 on t1.micro)

I have a zip with a precompiled version of nodejs, this makes me skip compile time the next time I need it!

Run this script as root or put in the userdata field.

#!/bin/bash apt-get update -y apt-get upgrade -y apt-get install -y \ git-core build-essential \ openssl \ libssl-dev \ zip \ --fix-missing git clone http://github.com/joyent/node.git && cd node git checkout v0.4.12 ./configure JOBS=2 make cd zip -r node-v0.4.12-c.zip node git clone http://github.com/isaacs/npm.git && cd npm git checkout v1.0.104 && make install cd ../ rm -rf npm rm -rf node mkdir s3-uploader && cd s3-uploader npm install knox cat < uploader.js >> EOF var knox = require('knox'), fs = require('fs'); var client = knox.createClient({ key: 'S3_API_KEY' , secret: 'S3_API_SECRET' , bucket: 'S3_BUCKET_ID' }); fs.readFile('../node-' + process.version + '-c.zip', function(err, buf){ var req = client.put('node-' + process.version + '-c.zip', { 'Content-Length': buf.length , 'Content-Type': 'text/plain' }); req.on('response', function(res){ if (200 == res.statusCode) { console.log('saved to %s', req.url); } }); req.end(buf); }); EOF node uploader.js 

you can complete the first server, and the next time you start the same instance, you must put this in your userdata instance and skip compilation.

 #!/bin/bash wget –O node-v0.4.12-c.zip https://s3.amazonaws.com/[your-bucket-name]/node-[your-nodejs-version]-c.zip unzip node-[your-nodejs-version]-c.zip cd node make install cd ../ rm -rf node rm -rf node-[your-nodejs-version]-c.zip 
+1
source

All Articles