How to run Node controlled Phantomjs/Casperjs script in Heroku
The issue actually had nothing to do with Heroku. As noted in this SO answer, using exec and providing any environmental variables in the options parameter replaces the entire set of environment variables. This includes the path, effectively overwriting any paths already specified to Heroku in the buildpack and npm modules.
You can create a copy of process.env and pass that along in the parameters in addition to other environmental parameters needed to be passed.
Run a phantom.js file on Heroku regularly
Found it: I only had to write
phantomjs phantom.js
in order to get it working. It was the "run" that made the expression invalid
Is there a working nodejs/phantomjs Heroku buildpack?
Heroku Toolbelt now has first class support for multiple buildpacks, so you can get a working Node and PhantomJS setup with the following:
heroku buildpacks:set https://github.com/heroku/heroku-buildpack-nodejs.git
heroku buildpacks:add --index 1 https://github.com/stomita/heroku-buildpack-phantomjs.git
Deploy phantomJS to node.js app?
Copy the lib folder of phantomjs to the root directory of your node app
You could also try putting a sym link in bin or sbin
The key is that is has to run from terminal using the same account that node runs on.
Also, node-phantom is a good npm library to utilize phantomjs, once you get it working.
Page-break-inside support in phantomjs on heroku
I've downloaded it to my machine(Debian 7.6.0) and compiled PhantomJS using this guide.
So I executed:
sudo apt-get update
sudo apt-get install build-essential chrpath git-core libssl-dev libfontconfig1-dev libxft-dev
git clone git://github.com/ariya/phantomjs.git
cd phantomjs
git checkout 1.9
./build.sh
And then I took the binary from /bin
folder and added it to custom buildpack. I added this buildpack to heroku, but it crashed with the following error:
/phantomjs: /usr/lib/libstdc++.so.6: version `GLIBCXX_3.4.15' not found (required by ./phantomjs)
So I did on my machine
ldd bin/phantomjs
and I took all dependencies:
root@deepsypotato:/home/viktor# ldd phantomjs.1
linux-vdso.so.1 => (0x00007fffe9f74000)
libfreetype.so.6 => /usr/lib/x86_64-linux-gnu/libfreetype.so.6 (0x00007fd914fcd000)
libfontconfig.so.1 => /usr/lib/x86_64-linux-gnu/libfontconfig.so.1 (0x00007fd914d96000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fd914b91000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007fd914989000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fd91476d000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fd914465000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fd9141e3000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fd913fcd000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fd913c41000)
/lib64/ld-linux-x86-64.so.2 (0x00007fd915283000)
libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007fd913a2a000)
libexpat.so.1 => /lib/x86_64-linux-gnu/libexpat.so.1 (0x00007fd913800000)
then I copied libstdc++.so.6
from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
and added it to my custom buildpack and now its working flawlessly :).
Related Topics
Optimization for Finding Perfect-Square Algorithm
Ruby - Elegantly Convert Variable to an Array If Not an Array Already
How to Fix a Deadlock Caused by Open
Why Doesn't 'User Installation Directory' Match with the Ruby Version
How to List All Versions of a Gem Available at a Remote Site
How to Set Up a Sinatra App Under Apache with Passenger
What Is the &: of &:Afunction Doing
How to Find Where Gem Files Are Installed
How to Step Out of a Loop with Ruby Pry
Rails: Convert Utc Datetime to Another Time Zone
What Is Mattr_Accessor in a Rails Module
When We Import CSV Data, How Eliminate "Invalid Byte Sequence in Utf-8"
Cannot Access Local Sinatra Server from Another Computer on Same Network
Rails, How to Render a View/Partial in a Model
Rails Authentication Across Apps/Servers
File.Open, Open and Io.Foreach in Ruby, What Is the Difference