烧瓶uWSGI NGINX PyPDF2

烧瓶uWSGI NGINX PyPDF2,nginx,flask,uwsgi,pdfkit,pypdf2,Nginx,Flask,Uwsgi,Pdfkit,Pypdf2,我对ubuntu 18上的应用程序有问题 有来自uWSGI和NGINX的烧瓶 下面的错误生成函数 def print_report(year,month): import pdfkit, os import app.DB.employee_data as EMP from PyPDF2 import PdfFileMerger, PdfFileReader from flask import send_file emp_list = EMP.emp_list() output_pdf=PdfFi

我对ubuntu 18上的应用程序有问题

有来自uWSGI和NGINX的烧瓶

下面的错误生成函数

def print_report(year,month):
import pdfkit, os
import app.DB.employee_data as EMP
from PyPDF2 import PdfFileMerger, PdfFileReader
from flask import send_file
emp_list = EMP.emp_list()
output_pdf=PdfFileMerger()
options = {'enable-local-file-access': None}

for emp in emp_list:
    dir_path = os.path.dirname(os.path.realpath(__file__))
    print(dir_path)
    rendered=pracownicy_detail(emp[0],emp[1],year,month)
    pdf = pdfkit.from_string(rendered, 'pdfs/{imie}-{nazwisko}.pdf'.format(imie=emp[0].strip(), nazwisko=emp[1].strip()), options=options)
    output_pdf.append(PdfFileReader('pdfs/{imie}-{nazwisko}.pdf'.format(imie=emp[0].strip(), nazwisko=emp[1].strip()), 'rb'),import_bookmarks=False)
    #usunac pozostale pliki
    os.remove('pdfs/{imie}-{nazwisko}.pdf'.format(imie=emp[0].strip(), nazwisko=emp[1].strip()))
output_pdf.write('pdfs/raport.pdf')

return send_file('../pdfs/raport.pdf', as_attachment=True)
使用uswgi app.ini命令手动启动的应用程序100%正常工作

作为app.service运行会生成“内部服务器错误”

应用程序服务

[Unit]
Description=A simple Flask uWSGI application
After=network.target

[Service]
User=ubuntu-app
Group=www-data
WorkingDirectory=/home/ubuntu-app/app
Environment="PATH=/home/ubuntu-app/app/env/bin"
ExecStart=/home/ubuntu-app/app/env/bin/uwsgi --ini app.ini

[Install]
WantedBy=multi-user.target
NGINX设置

server {
    listen 80;
    server_name 192.168.2.120;

    location / {
        include uwsgi_params;
        uwsgi_pass unix:/home/ubuntu-app/app/app.sock;
    }
}
下面是app.ini

[uwsgi]
; Production .ini file
module = run:app
master = true

; There is no magic rule for setting the number of processes or threads to use.
; It is very much application and system dependent so you'll need to experiment.
processes = 2
threads = 2



socket = app.sock
chmod-socket = 666
vacuum = true
die-on-term = true
解决办法是增加:

config = pdfkit.configuration(wkhtmltopdf=bytes('/usr/local/bin/wkhtmltopdf', 'utf-8'))