NodeJS永远在AWS EC2上构build

我正在尝试在EC2上设置NodeJS。

我遵循官方指南,并在我的本地机器上成功。 但是,在EC2上编译源代码时,需要永久完成(2小时计算)。 我想这与CPU限制或超时有关。

我不熟悉Linux和makefile。 有没有办法绕过呢? 谢谢,

我猜你正在使用微型实例。 是的,这将需要一段时间 – 微型实例在短时间内获得大量的CPU,如果你使用一段时间的CPU会受到严重的封锁。 编译node.js是CPU密集型的。

在光明的一面,你只需要做一次。 完成之后,创build一个AMI,并且可以根据需要启动尽可能多的预装了node.js的服务器。

你有什么发行? 我使用的是Ubuntu 10.04 LTS(t1.micro上的ami-ad36fbc4)

我有一个预编译的nodejs版本的zip,这使我能够在下次需要时跳过编译时间!

以root身份运行此脚本,或放入userdata字段。

#!/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 

你可以终止第一台服务器,下次运行同一个实例时,你必须把实例userdata放在这个实例中,然后跳过编译。

 #!/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