【发布时间】:2017-10-03 16:19:20
【问题描述】:
我正在尝试将 unicorn 更改为 puma,但 pdfkit 有问题。要将 pdf 与 unicorn 一起使用,我必须从 3 名工人开始,但如果我对 puma 做同样的事情,它会停止在 55%。
这是我的 puma 配置。
# config/puma.rb
port 3000
threads 0, 16
workers 3
我在开始时的日志:
=> Booting Puma
=> Rails 4.2.6 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
[23551] Puma starting in cluster mode...
[23551] * Version 3.8.2 (ruby 2.3.1-p112), codename: Sassy Salamander
[23551] * Min threads: 0, max threads: 16
[23551] * Environment: development
[23551] * Process workers: 4
[23551] * Preloading application
[23551] * Listening on tcp://localhost:3000
[23551] Use Ctrl-C to stop
[23551] - Worker 0 (pid: 23571) booted, phase: 0
[23551] - Worker 1 (pid: 23580) booted, phase: 0
[23551] - Worker 2 (pid: 23589) booted, phase: 0
[23551] - Worker 3 (pid: 23598) booted, phase: 0
并在我尝试创建 pdf 时记录(它永远不会完成)。
Completed 200 OK in 40ms (Views: 4.2ms | ActiveRecord: 5.7ms)
[=================================> ] 55%
我必须说的另一件事是,在我的布局中,我使用了类似的东西(它通过请求将页眉和页脚渲染到同一个应用程序):
- if request_from_pdfkit?
%meta{:name => 'pdfkit-header_html', :content => pdf_header_url(:protocol => 'http', :codigo =>params[:title])}
%meta{:name => 'pdfkit-footer_html', :content => pdf_footer_url(:protocol => 'http', :codigo =>params[:title])}
感谢您的帮助!
编辑: 我做了其他尝试,我创建了 2 个端点,1 个让应用程序长时间休眠(/sleeprequest),其他渲染一个基本的 json(/examplerequest)。 我从相同的配置开始,如果我执行 /seleeprequest,应用程序将被阻止并且不接受 /examplerequest。
在此之前我有一个带有这个基本配置的 nginx(我不知道它是否有问题):
location / {
proxy_pass http://127.0.0.1:3000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
还有我的流程
ps aux | grep puma
alejand+ 29391 2.1 1.2 573648 206572 pts/22 Sl+ 10:18 0:07 puma 3.8.2 (tcp://localhost:3000)
alejand+ 29413 1.0 2.2 1193920 365412 pts/22 Sl+ 10:18 0:03 puma: cluster worker 0: 29391
alejand+ 29422 0.5 1.9 1180024 313324 pts/22 Sl+ 10:18 0:01 puma: cluster worker 1: 29391
alejand+ 29431 0.5 2.0 1180024 329728 pts/22 Sl+ 10:18 0:02 puma: cluster worker 2: 29391
【问题讨论】:
-
我认为问题与应用服务器无关。在 devlopment.log 或 production.log 或 puma.log 中找到 pdfkit 的错误日志并展示给我们。
-
Pdfkit 不显示错误,它尝试渲染视图,为此我需要 3 个工作人员。 1 用于主请求,其他 2 用于页眉和页脚。与独角兽和 3 名工人一起工作。我认为我的配置有问题。
标签: ruby-on-rails puma pdfkit