Rails 开发服务器、PDFKit 和多线程 [英] Rails development server, PDFKit and multithread

查看:42
本文介绍了Rails 开发服务器、PDFKit 和多线程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 rails 应用程序,它使用 PDFKit 来呈现网页的 pdf 版本.我使用 Thin 作为开发服务器.

I have a rails app that uses PDFKit to render pdf versions of webpages. I use Thin as a development server.

问题是当我处于开发模式时.当我使用bundle exec rails s"启动我的服务器并尝试渲染任何 PDF 时,整个过程会陷入僵局,因为当您渲染 PDF 时,会向服务器请求一些额外的资源(如图像和 css),并且看起来好像只有一个线程.

The problem is that when i'm in development mode. When I start my server with "bundle exec rails s" and I try to render any PDF the whole process gets deadlocked because when you render a PDF some extra resources like images and css are requested to the server and looks like there is a single thread.

如何配置 Rails 开发服务器以运行多个工作线程?

How can I configure rails development server to run multiple worker threads?

非常感谢.

推荐答案

我找到的最简单的解决方案是 unicorn.

The simplest solution I have found is unicorn.

gem install unicorn

创建一个unicorn.conf:

worker_processes 3

然后使用它:

my_gem_tree/bin/unicorn_rails -c unicorn.conf

这篇关于Rails 开发服务器、PDFKit 和多线程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆