2

在我的 Rails 应用程序中有一个方法(旨在通过 Rake 任务触发),它可以运行并运行 PhantomJS 进程:

bin/proximo bin/phantomjs vendor/assets/javascripts/yslow.js http://www.example.com

可执行文件是 1.8.1 或 Linux ( phantomjsx86-64)。yslow.js对于 PhantomJS 3.1.1 是 YSlow。

该过程是通过 Heroku 的 Proximo 插件运行的,因为我正在针对的网站(上面的 example.com)将向任何未列入白名单的 IP 显示反 DOS 保护页面。

我遇到的问题是这个命令只是挂起,没有返回任何输出。如果我在不执行bin/proximo包装脚本的情况下运行相同的命令,它可以工作,但是由于上面提到的 IP 限制,我当然会得到错误页面的输出。

这是直接在 Heroku 上的 Rails 控制台中运行的堆栈跟踪:

irb(main):023:0> `bin/proximo bin/phantomjs vendor/assets/javascripts/yslow.js http://www.example.com`
^CIRB::Abort: abort then interrupt!
  from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.11/lib/active_support/core_ext/kernel/agnostics.rb:7:in `call'
  from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.11/lib/active_support/core_ext/kernel/agnostics.rb:7:in ``'
  from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.11/lib/active_support/core_ext/kernel/agnostics.rb:7:in ``'
  from (irb):23
  from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.11/lib/rails/commands/console.rb:47:in `start'
  from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.11/lib/rails/commands/console.rb:8:in `start'
  from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.11/lib/rails/commands.rb:41:in `<top (required)>'
  from script/rails:6:in `require'
  from script/rails:6:in `<main>'

任何想法是什么导致挂起?


编辑:我的同事帮助我发现挂起的实际上是 PhantomJS,而不是代理。我会寻找另一种销售 PhantomJS 的方式,除非其他人有其他建议。

编辑 2:我用 Heroku buildpack 安装了 PhantomJS,同样的事情发生了。我还注意到,如果我连接到 Heroku 上的 Bash shell 并运行phantomjs控制台,我无法在其中输入命令,因为 enter 键什么都不做。不知道有没有关系...

4

0 回答 0