Ruby on Rails调用perl脚本超时



我正在编写一个使用Open3调用perl脚本的Ruby on Rails应用程序。然而,当调用perl脚本时,我的应用程序不断抛出超时::错误比我想要的更快。我调用脚本的代码如下所示:

Timeout::timeout(120){
@stdout, @stderr, @exit_code  = Open3.capture3(@command)
[@exit_code.to_i, @stdout, @stderr]
}

我意识到调用一个潜在的"长"运行脚本(可能最多20-30秒)对于ruby on rails应用程序来说并不理想,但我没有太多的选择。

我使用独角兽来获得并发性,我将独角兽超时设置为60s。尽管我的独角兽文件中有60秒超时,Open3调用中有120秒超时,但我的请求始终超时在18秒左右。我知道脚本成功完成,因为我看到另一边的结果,但我需要我的应用程序等待脚本的返回。

是否有其他方法可以强制我的rails应用程序等待而不是超时?

谢谢!

从捕获的错误回溯:

<>之前执行过期森/opt//ruby/lib/ruby 1.9.1/open3。rb: 280:在"价值"森/opt//ruby/lib/ruby 1.9.1/open3。在' block in capture3'森/opt//ruby/lib/ruby 1.9.1/open3。rb: 208:"popen_run"森/opt//ruby/lib/ruby 1.9.1/open3。rb: 90:"popen3"森/opt//ruby/lib/ruby 1.9.1/open3。rb: 270:"capture3"森/opt//双极性晶体管/版本/aa47354a897077a6600349fd6c473704bb17f929/app/模型/perl_exec。在' block in execute'森/opt//ruby/lib/ruby/1.9.1/超时。rb: 68:"超时"森/opt//双极性晶体管/版本/aa47354a897077a6600349fd6c473704bb17f929/app/模型/perl_exec。rb: 22:在"执行"森/opt//双极性晶体管/版本/aa47354a897077a6600349fd6c473704bb17f929/app/模型/水库。rb: 47:在"执行!"森/opt//双极性晶体管/版本/aa47354a897077a6600349fd6c473704bb17f929/app/模型/预订。rb: 93:在"承诺!"森/opt//双极性晶体管/版本/aa47354a897077a6600349fd6c473704bb17f929/app/controllers/reservations_controller。在' block in commit'森/opt//ruby/lib/ruby/1.9.1/超时。rb: 68:"超时"森/opt//双极性晶体管/版本/aa47354a897077a6600349fd6c473704bb17f929/app/controllers/reservations_controller。rb: 105:在"提交"森/opt//ruby/lib/ruby/宝石/1.9.1/珠宝/actionpack-3.2.9/lib/action_controller/金属/implicit_render。rb: 4:在"send_action"森/opt//ruby/lib/ruby/宝石/1.9.1/珠宝/actionpack-3.2.9/lib/abstract_controller/基地。rb: 167:"process_action"森/opt//ruby/lib/ruby/宝石/1.9.1/珠宝/actionpack-3.2.9/lib/action_controller/金属/渲染。rb: 10:在"process_action"森/opt//ruby/lib/ruby/宝石/1.9.1/珠宝/actionpack-3.2.9/lib/abstract_controller/回调。在' block in process_action'森/opt//ruby/lib/ruby/宝石/1.9.1/珠宝/activesupport-3.2.9/lib/active_support/回调。rb: 469:"_run__3753465240598785610__process_action__3320622668841691210__callbacks"森/opt//ruby/lib/ruby/宝石/1.9.1/珠宝/activesupport-3.2.9/lib/active_support/回调。rb: 405:"__run_callback"森/opt//ruby/lib/ruby/宝石/1.9.1/珠宝/activesupport-3.2.9/lib/active_support/回调。rb: 385:"_run_process_action_callbacks"森/opt//ruby/lib/ruby/宝石/1.9.1/珠宝/activesupport-3.2.9/lib/active_support/回调。rb: 81:"run_callbacks"森/opt//ruby/lib/ruby/宝石/1.9.1/珠宝/actionpack-3.2.9/lib/abstract_controller/回调。rb: 17:在"process_action"森/opt//ruby/lib/ruby/宝石/1.9.1/珠宝/actionpack-3.2.9/lib/action_controller/金属/救援。rb: 29:"process_action"森/opt//ruby/lib/ruby/宝石/1.9.1/珠宝/actionpack-3.2.9/lib/action_controller/金属/仪器。在' block in process_action'森/opt//ruby/lib/ruby/宝石/1.9.1/珠宝/activesupport-3.2.9/lib/active_support/通知。Rb:123:在' block in instrument'中森/opt//ruby/lib/ruby/珠宝/1.9.1/珠宝/activesupport-3.2.9/lib/active_support/通知/插装器。rb: 20:在"工具"森/opt//ruby/lib/ruby/宝石/1.9.1/珠宝/activesupport-3.2.9/lib/active_support/通知。rb: 123:在"工具"森/opt//ruby/lib/ruby/宝石/1.9.1/珠宝/actionpack-3.2.9/lib/action_controller/金属/仪器。rb: 29:"process_action"森/opt//ruby/lib/ruby/宝石/1.9.1/珠宝/actionpack-3.2.9/lib/action_controller/金属/params_wrapper。rb: 207:"process_action"森/opt//ruby/lib/ruby/珠宝/1.9.1/珠宝/activerecord-3.2.9/lib/active_record/railties/controller_runtime。rb: 18:在"process_action"森/opt//ruby/lib/ruby/宝石/1.9.1/珠宝/actionpack-3.2.9/lib/abstract_controller/基地。rb: 121:在"过程"森/opt//ruby/lib/ruby/宝石/1.9.1/珠宝/actionpack-3.2.9/lib/abstract_controller/渲染。rb: 45:在"过程"森/opt//ruby/lib/ruby/宝石/1.9.1/珠宝/actionpack-3.2.9/lib/action_controller/金属。rb: 203:"调度"森/opt//ruby/lib/ruby/宝石/1.9.1/珠宝/actionpack-3.2.9/lib/action_controller/金属/rack_delegation。rb: 14:"调度"森/opt//ruby/lib/ruby/宝石/1.9.1/珠宝/actionpack-3.2.9/lib/action_controller/金属。246:在' block in action'森/opt//ruby/lib/ruby/珠宝/1.9.1/珠宝/actionpack-3.2.9/lib/action_dispatch/路由/route_set。rb: 73:在"调用"森/opt//ruby/lib/ruby/珠宝/1.9.1/珠宝/actionpack-3.2.9/lib/action_dispatch/路由/route_set。rb: 73:"调度"森/opt//ruby/lib/ruby/珠宝/1.9.1/珠宝/actionpack-3.2.9/lib/action_dispatch/路由/route_set。rb: 36:在"调用"森/opt//ruby/lib/ruby/宝石/1.9.1/珠宝/journey-1.0.4/lib/旅行/路由器。在' block in call'中森/opt//ruby/lib/ruby/宝石/1.9.1/珠宝/journey-1.0.4/lib/旅行/路由器。rb: 56:"每一个"森/opt//ruby/lib/ruby/宝石/1.9.1/珠宝/journey-1.0.4/lib/旅行/路由器。rb: 56:在"调用"森/opt//ruby/lib/ruby/珠宝/1.9.1/珠宝/actionpack-3.2.9/lib/action_dispatch/路由/route_set。rb: 601:在"调用"森/opt//ruby/lib/ruby/宝石/1.9.1/珠宝/rack-timeout-0.0.3/lib/架/超时。在' block in call'中森/opt//ruby/lib/ruby/1.9.1/超时。rb: 68:"超时"森/opt//ruby/lib/ruby/宝石/1.9.1/珠宝/rack-timeout-0.0.3/lib/架/超时。rb: 16:在"调用"/opt/森/双极性晶体管/版本/aa47354a897077a6600349fd6c473704bb17f929/应用/中间件/nestful。rb: 18:在"调用"森/opt//ruby/lib/ruby/珠宝/1.9.1/珠宝/actionpack-3.2.9/lib/action_dispatch/中间件/bestrongtandards_support。rb: 17:在"调用"森/opt//ruby/lib/ruby/宝石/1.9.1/珠宝/rack-1.4.1/lib/架/etag。rb: 23:"叫"森/opt//ruby/lib/ruby/宝石/1.9.1/珠宝/rack-1.4.1/lib/架/conditionalget。rb: 35:"叫"森/opt//ruby/lib/ruby/宝石/1.9.1/珠宝/actionpack-3.2.9/lib/action_dispatch/中间件/头。rb: 14:在"调用"森/opt//ruby/lib/ruby/珠宝/1.9.1/珠宝/actionpack-3.2.9/lib/action_dispatch/中间件/params_parser。rb: 21:在"调用"森/opt//ruby/lib/ruby/宝石/1.9.1/珠宝/actionpack-3.2.9/lib/action_dispatch/中间件/闪光。rb: 242:在"调用"森/opt//ruby/lib/ruby/珠宝/1.9.1/珠宝/rack-1.4.1/lib/架/会议/文摘/id。rb: 205:在"上下文"森/opt//ruby/lib/ruby/珠宝/1.9.1/珠宝/rack-1.4.1/lib/架/会议/文摘/id。rb: 200:在"调用"森/opt//ruby/lib/ruby/宝石/1.9.1/珠宝/actionpack-3.2.9/lib/action_dispatch/中间件/饼干。rb: 341:在"调用"森/opt//ruby/lib/ruby/宝石/1.9.1/珠宝/activerecord-3.2.9/lib/active_record/query_cache。rb: 64:在"调用"森/opt//ruby/lib/ruby/宝石/1.9.1/珠宝/activerecord-3.2.9/lib/active_record/connection_adapters/文摘/connection_pool。rb: 479:在"调用"森/opt//ruby/lib/ruby/宝石/1.9.1/珠宝/actionpack-3.2.9/lib/action_dispatch/中间件/回调。Rb:28:在' block in call'森/opt//ruby/lib/ruby/宝石/1.9.1/珠宝/activesupport-3.2.9/lib/active_support/回调。rb: 405:"_run__4121137639594084607__call__1985817909290506524__callbacks"森/opt//ruby/lib/ruby/宝石/1.9.1/珠宝/activesupport-3.2.9/lib/active_support/回调。rb: 405:"__run_callback"森/opt//ruby/lib/ruby/宝石/1.9.1/珠宝/activesupport-3.2.9/lib/active_support/回调。rb: 385:"_run_call_callbacks"森/opt//ruby/lib/ruby/宝石/1.9.1/珠宝/activesupport-3.2.9/lib/active_support/回调。rb: 81:"run_callbacks"森/opt//ruby/lib/ruby/宝石/1.9.1/珠宝/actionpack-3.2.9/lib/action_dispatch/中间件/回调。rb: 27日:在"调用"森/opt//ruby/lib/ruby/珠宝/1.9.1/珠宝/actionpack-3.2.9/lib/action_dispatch/中间件/remote_ip。rb: 31:在"调用"森/opt//ruby/lib/ruby/珠宝/1.9.1/珠宝/actionpack-3.2.9/lib/action_dispatch/中间件/debug_exceptions。rb: 16:在"调用"森/opt//ruby/lib/ruby/珠宝/1.9.1/珠宝/actionpack-3.2.9/lib/action_dispatch/中间件/show_exceptions。rb: 56:在"调用"森/opt//ruby/lib/ruby/珠宝/1.9.1/珠宝/railties-3.2.9/lib/rails/架/记录器。rb: 32:"call_app"森/opt//ruby/lib/ruby/珠宝/1.9.1/珠宝/railties-3.2.9/lib/rails/架/记录器。在' block in call'中森/opt//ruby/lib/ruby/宝石/1.9.1/珠宝/activesupport-3.2.9/lib/active_support/tagged_logging。rb: 22:在"标记"森/opt//ruby/lib/ruby/珠宝/1.9.1/珠宝/railties-3.2.9/lib/rails/架/记录器。rb: 16:在"调用"森/opt//ruby/lib/ruby/珠宝/1.9.1/珠宝/actionpack-3.2.9/lib/action_dispatch/中间件/request_id。rb: 22:在"调用"森/opt//ruby/lib/ruby/宝石/1.9.1/珠宝/rack-1.4.1/lib/架/methodoverride。rb: 21:在"调用"森/opt//ruby/lib/ruby/宝石/1.9.1/珠宝/rack-1.4.1/lib/架/运行时。rb: 17:在"调用"森/opt//ruby/lib/ruby/珠宝/1.9.1/珠宝/activesupport-3.2.9/lib//local_cache active_support/缓存策略。rb: 72:在"调用"森/opt//ruby/lib/ruby/宝石/1.9.1/珠宝/rack-1.4.1/lib/架/锁。rb: 15:在"调用"森/opt//ruby/lib/ruby/宝石/1.9.1/珠宝/actionpack-3.2.9/lib/action_dispatch/中间件/静态的。rb: 62:在"调用"森/opt//ruby/lib/ruby/宝石/1.9.1/珠宝/架-缓存- 1.2/lib/架/缓存/上下文。rb: 136:"向前"森/opt//ruby/lib/ruby/宝石/1.9.1/珠宝/架-缓存- 1.2/lib/架/缓存/上下文。rb: 143:在"通过"森/opt//ruby/lib/ruby/宝石/1.9.1/珠宝/架-缓存- 1.2/lib/架/缓存/上下文。rb: 155:在"无效"森/opt//ruby/lib/ruby/宝石/1.9.1/珠宝/架-缓存- 1.2/lib/架/缓存/上下文。rb: 71:"叫!"森/opt//ruby/lib/ruby/宝石/1.9.1/珠宝/架-缓存- 1.2/lib/架/缓存/上下文。rb: 51:在"调用"森/opt//ruby/lib/ruby/宝石/1.9.1/珠宝/railties-3.2.9/lib/铁路/引擎。rb: 479:在"调用"森/opt//ruby/lib/ruby/宝石/1.9.1/珠宝/railties-3.2.9/lib/rails应用程序。rb: 223:在"调用"森/opt//ruby/lib/ruby/宝石/1.9.1/珠宝/railties-3.2.9/lib/铁路/railtie/可配置的。rb: 30:"method_missing"森/opt//ruby/lib/ruby/宝石/1.9.1/珠宝/unicorn-4.6.2/lib/独角兽/http_server。rb: 552:"process_client"森/opt//ruby/lib/ruby/宝石/1.9.1/珠宝/unicorn-4.6.2/lib/独角兽/http_server。rb: 632:"worker_loop"森/opt//ruby/lib/ruby/宝石/1.9.1/珠宝/unicorn-4.6.2/lib/独角兽/http_server。rb: 500:"spawn_missing_workers"森/opt//ruby/lib/ruby/宝石/1.9.1/珠宝/unicorn-4.6.2/lib/独角兽/http_server。rb: 142:在"开始"森/opt//ruby/lib/ruby/宝石/1.9.1/珠宝/unicorn-4.6.2/bin/unicorn_rails: 209:在"森/opt//ruby/bin/unicorn_rails: 23:"负载"森/opt//ruby/bin/unicorn_rails: 23:"

从堆栈跟踪中可以看到

/opt/sen/ruby/lib/ruby/gems/1.9.1/gems/rack-timeout-0.0.3/lib/rack/timeout.rb:16:in `call'
您有一个Rack中间件(Rack -timeout),它在整个请求上强制一个额外的超时。配置或删除中间件,你应该很好。

相关内容

  • 没有找到相关文章

最新更新