1

我使用以下 buildpack 在 herouku 上构建了一个 phantomjs / nodejs 应用程序,但没有成功:

http://github.com/heroku/heroku-buildpack-nodejs.git

http://github.com/heroku/heroku-buildpack-nodejs http://github.com/stomita/heroku-buildpack-phantomjs

phantom stderr: execvp(): Permission denied
/app/web.js:127
          return ph.createPage(function(err, page) {
                    ^
TypeError: Cannot call method 'createPage' of undefined
     at phantom.create.phantomPath (/app/web.js:127:18)

我的 webjs 是:

app.get('/', function(req, res){
  // If there is _escaped_fragment_ option, it means we have to
  // generate the static HTML that should normally return the Javascript

  if(typeof(req.query._escaped_fragment_) !== "undefined") {
    phantom.create(function(err, ph) {
      return ph.createPage(function(err, page) {
        // We open phantomJS at the proper page.
        return page.open("http://myurl.com/#!" + req.query._escaped_fragment_, function(status) {
          return page.evaluate((function() {
            // We grab the content inside <html> tag...
            return document.getElementsByTagName('html')[0].outerHTML;
          }), function(err, result) {
            // ... and we send it to the client.
            res.send(result);
            return ph.exit();
          });
        });
      });
    },{phantomPath:"/app/vendor/phantomjs/bin"});
  }
  else
    // If there is no _escaped_fragment_, we return the normal index template.
    //res.render('index');
    res.sendfile(__dirname + '/app/index.html');
});

如果我在 Macbook 上本地运行它,它可以工作,我使用 node-phantom-simple 没有 socket.io 和集群支持。我无法更改 phantomjs 二进制文件的权限,它们始终保持 700,heroku 支持告诉我,我负责通过 buildpack 对文件的权限。

有什么建议么?

谢谢,帕特里克

4

0 回答 0