简体   繁体   English

Django wkhtmltopdf 加载卡住

[英]Django wkhtmltopdf loading stuck

same issue.同样的问题。 Just checking if it has been solved.只是检查它是否已经解决。 More context: I'm using django-wkhtmltopdf 3.3.0 and wkhtmltopdf 0.12.5 (with patched qt) on ubuntu.更多上下文:我在 ubuntu 上使用 django-wkhtmltopdf 3.3.0 和 wkhtmltopdf 0.12.5(带有修补的 qt)。

options = {
    'title': "PDF Title",
    'page-size': 'A4',
    'orientation': 'portrait',
    'margin-top': '20mm',
    'margin-right': '10mm',
    'margin-bottom': '20mm',
    'margin-left': '10mm',
    'load-error-handling': 'ignore',
    'quiet': None,
    'enable-local-file-access': True,
    'header-spacing': 5,
    'footer-spacing': 5,
}

When I run this command, my server gets stuck with this message:当我运行此命令时,我的服务器会收到以下消息:

Loading pages (1/6)
[=================>                                          ] 29%

If I ctrl C my server, I can see the command that was running:如果我 ctrl C 我的服务器,我可以看到正在运行的命令:

/usr/local/bin/wkhtmltopdf --enable-local-file-access --encoding utf8 --footer-spacing 5 --footer-html /tmp/wkhtmltopdfap_vk62a.html --header-spacing 5 --header-html /tmp/wkhtmltopdfhfdro6i1.html --load-error-handling ignore --margin-bottom 20mm --margin-left 10mm --margin-right 10mm --margin-top 20mm --orientation portrait --page-size A4 --title "PDF Title" /tmp/wkhtmltopdfku94woo9.html - 

The latter works fine when execute on bash (or python shell).后者在 bash(或 python shell)上执行时工作正常。

Thank you random stack overflow shell deities.谢谢随机堆栈溢出 shell 神。

Seems the problem is from static files loading.似乎问题来自 static 文件加载。

wkhtmltopdf tries loading the static files from "localhost:8000/static" but that port is already busy, awaiting to respond to the query calling wkhtmltopdf. wkhtmltopdf 尝试从“localhost:8000/static”加载 static 文件,但该端口已经很忙,等待响应调用 wkhtmltopdf 的查询。 Some sort of mutual exclusion.某种互斥。

Edit: I fixed this by adding moving the static files to an nginx server on port 8081, and serving them from there.编辑:我通过添加将 static 文件移动到端口 8081 上的 nginx 服务器并从那里提供服务来解决此问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM