diff --git a/.gitignore b/.gitignore index 37d7e73..4b21fc6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ node_modules .env +context.json +*.env diff --git a/build-phantomjs.sh b/build-phantomjs.sh deleted file mode 100644 index 2337179..0000000 --- a/build-phantomjs.sh +++ /dev/null @@ -1,32 +0,0 @@ -# Launch an EC2 instance using the region-appropriate AMI from this document: -# http://docs.aws.amazon.com/lambda/latest/dg/current-supported-versions. - -# Use a fairly beefy Spot Instance (c4.large is good) unless you want to wait -# for a long time. Don't bother with a t2.micro. - -# Once it starts, SSH into the machine: - -ssh ec2-user@your-ec2-box.amazonaws.com - -# And then run (following the instructions from -# http://phantomjs.org/build.html): - -sudo yum -y install gcc gcc-c++ make flex bison gperf ruby \ - openssl-devel freetype-devel fontconfig-devel libicu-devel sqlite-devel \ - libpng-devel libjpeg-devel - -wget https://github.com/ariya/phantomjs/archive/1.9.7.zip -unzip 1.9.7.zip -cd phantomjs-1.9.7/ -./build.sh --confirm - -# Once it's finished, retrieve the build product (run from your local machine): -scp ec2-user@your-ec2-box.amazonaws.com:phantomjs-1.9.7/bin/phantomjs . - -# Since this AMI includes a newer version of libicudata than Amazon Lambda, -# we need to include those libraries too. -# This won't be necessary once -# https://github.com/ariya/phantomjs/issues/12948 is fixed. -scp ec2-user@your-ec2-box.amazonaws.com:"/usr/lib64/libicu*50" . - -# That's it! Don't forget to terminate the EC2 instance. diff --git a/index.js b/index.js index a6b0b0d..6fb0ddb 100644 --- a/index.js +++ b/index.js @@ -6,15 +6,14 @@ exports.handler = function( event, context ) { fs = require('fs'), os = require('os'), http = require('http'), - phantomDownloadPath = "https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-1.9.8-linux-x86_64-symbols.tar.bz2", childProcess = require('child_process'); // Get the path to the phantomjs application function getPhantomFileName(callback) { - var nodeModulesPath = path.join(__dirname, 'node_modules'); + var nodeModulesPath = path.join(__dirname, 'node_modules', 'phantomjs-prebuilt'); fs.exists(nodeModulesPath, function(exists) { if (exists) { - callback(path.join(__dirname, 'node_modules','phantomjs', 'bin', 'phantomjs')); + callback(path.join(__dirname, 'node_modules','phantomjs-prebuilt', 'bin', 'phantomjs')); } else { callback(path.join(__dirname, 'phantomjs')); @@ -25,11 +24,11 @@ exports.handler = function( event, context ) { // Call the phantomjs script function callPhantom(callback) { getPhantomFileName(function(phantomJsPath) { - + var childArgs = [ path.join(__dirname, 'phantomjs-script.js') ]; - + // replace default phantomjs script with something the invoker sent if (event && event.code) { childArgs[0] = generateTmpScript() @@ -48,20 +47,20 @@ exports.handler = function( event, context ) { console.log('Calling phantom: ', phantomJsPath, childArgs); var ls = childProcess.execFile(phantomJsPath, childArgs); - + ls.stdout.on('data', function (data) { // register one or more handlers console.log(data); }); - + ls.stderr.on('data', function (data) { console.log('phantom error ---:> ' + data); }); - + ls.on('exit', function (code) { console.log('child process exited with code ' + code); callback(); }); - + }); } diff --git a/libicudata.so.50 b/libicudata.so.50 deleted file mode 100755 index e1946a0..0000000 Binary files a/libicudata.so.50 and /dev/null differ diff --git a/libicui18n.so.50 b/libicui18n.so.50 deleted file mode 100755 index f4f08dc..0000000 Binary files a/libicui18n.so.50 and /dev/null differ diff --git a/libicuio.so.50 b/libicuio.so.50 deleted file mode 100755 index 050cc19..0000000 Binary files a/libicuio.so.50 and /dev/null differ diff --git a/libicule.so.50 b/libicule.so.50 deleted file mode 100755 index 6213ca6..0000000 Binary files a/libicule.so.50 and /dev/null differ diff --git a/libiculx.so.50 b/libiculx.so.50 deleted file mode 100755 index dcdacaf..0000000 Binary files a/libiculx.so.50 and /dev/null differ diff --git a/libicutest.so.50 b/libicutest.so.50 deleted file mode 100755 index 817a3ac..0000000 Binary files a/libicutest.so.50 and /dev/null differ diff --git a/libicutu.so.50 b/libicutu.so.50 deleted file mode 100755 index 4f14234..0000000 Binary files a/libicutu.so.50 and /dev/null differ diff --git a/libicuuc.so.50 b/libicuuc.so.50 deleted file mode 100755 index 4108453..0000000 Binary files a/libicuuc.so.50 and /dev/null differ diff --git a/package.json b/package.json index 19b7d19..044fffe 100644 --- a/package.json +++ b/package.json @@ -15,10 +15,10 @@ "homepage": "https://github.com/rebelmail/node-lambda-template", "dependencies": {}, "devDependencies": { - "aws-sdk": "^2.1.39", - "mocha": "^2.3.2", - "node-lambda": "^0.8.5", - "phantomjs": "^1.9.17" + "aws-sdk": "^2.7.8", + "mocha": "^3.2.0", + "node-lambda": "^0.8.11", + "phantomjs-prebuilt": "^2.1.13" }, "scripts": { "setup": "node-lambda setup", diff --git a/phantomjs b/phantomjs index ddedeba..d72e801 100755 Binary files a/phantomjs and b/phantomjs differ