使用Wand将PDF转换为PNG / JPG,通过Gunicorn中断生产,在调试服务器上很好

时间:2015-06-24 19:13:00

标签: django ubuntu imagemagick ghostscript wand

我正在尝试通过Wand将PDF转换为JPG / PNG。

这是代码(编辑)

os.path.isfile(os.path.join(settings.PROJECT_PATH, "file.pdf"):
    with Image(filename=os.path.join(settings.PROJECT_PATH, "file.pdf", resolution=100) as image:
        image.save(filename=os.path.join(settings.PROJECT_PATH, "file.jpg")

它完全适用于本地开发服务器,生产服务器上的开发服务器以及manage.py shell(生产服务器上)。

但是,当通过我的生产主管/ guncicorn设置使用时,我收到以下错误

DelegateError at /finance/api/v1/receipt/
Postscript delegate failed `/webapps/bab/bab/Beenie-Man-1.pdf': No such file or directory @ error/pdf.c/ReadPDFImage/677

这是startupscript。

#!/bin/bash

NAME="bab"                                  # Name of the application
DJANGODIR=/webapps/bab/bab             # Django project directory
SOCKFILE=/webapps/bab/run/gunicorn.sock  # we will communicte using this unix socket
USER=bab                                        # the user to run as
GROUP=webapps                                     # the group to run as
NUM_WORKERS=1                                     # how many worker processes should Gunicorn spawn
DJANGO_SETTINGS_MODULE=bab.settings             # which settings file should Django use
DJANGO_WSGI_MODULE=bab.wsgi                     # WSGI module name

echo "Starting $NAME as `whoami`"

# Activate the virtual environment
cd $DJANGODIR
source ../bin/activate
export DJANGO_SETTINGS_MODULE=$DJANGO_SETTINGS_MODULE
export PYTHONPATH=$DJANGODIR:$PYTHONPATH

# Create the run directory if it doesn't exist
RUNDIR=$(dirname $SOCKFILE)
test -d $RUNDIR || mkdir -p $RUNDIR

# Start your Django Unicorn
# Programs meant to be run under supervisor should not daemonize themselves (do not use --daemon)
exec ../bin/gunicorn ${DJANGO_WSGI_MODULE}:application \
  --name $NAME \
  --workers $NUM_WORKERS \
  --user=$USER --group=$GROUP \
  --log-level=debug \
  --bind=unix:$SOCKFILEchris@python:/webapps/bab$ 

当我在生产服务器上运行测试时,同时运行完整的调试服务器& shell,它正在使用正确的用户帐户&正确的virtualenv(并不是没有它就可以工作)

它可能是环境变量问题吗?还是某种许可事情?

0 个答案:

没有答案