0

In the past in order to make any os binary calls from Django over WSGI on Apache2 with a Debian server, I've had to use celeryd to queue the message, open a subprocess (Apache2 would not create a new child process for security reasons, but maybe there was another way - I couldn't seem to find one and this worked).

I found django-wkhtmltopdf wrapper and it works perfectly for my situation, run from the shell. When I run it from the web page, however, it gives me a CalledProcessError: Command returned non-zero exit status 1 with no other details in the logs or in the traceback.

Is this the same issue? Apache2 cannot call the subprocess for wkhtmltopdf because Apache2 is not allowing a child process?

Thanks for your help or any guidance where I can find some!

Furbeenator
  • 8,106
  • 4
  • 46
  • 54
  • What operating system are you using? Although creating sub processes from mod_wsgi processes is not recommended, there is generally nothing stopping you from doing that. You problems are more likely due to fact that under mod_wsgi it will run as Apache user by default and may not have write access to directories, or that current working directory is not where you expect. – Graham Dumpleton Dec 12 '16 at 23:25
  • Wow, no kidding? That would be amazing if that was the simple problem I spent countless hours solving a few years ago. I'm running Debian 7 and Apache2.2. Why is it not recommended for mod_wsgi to open a sub process? – Furbeenator Dec 12 '16 at 23:44
  • Because you inherit certain strange stuff from the Apache processes such as state of signal handler registrations. This can cause issues for example when running as a sub process a Java application as the signal that Java uses to do some stuff related to garbage collection is inherited as being ignored/blocked. You also can inherit open file descriptors as well, which may not be good from a security standpoint if what you are running in the sub process is code from an unknown third party. – Graham Dumpleton Dec 12 '16 at 23:48
  • This is on top of issues such as current working directory not being what you expect and user/file access permissions. On CentOS/Fedora/RHEL systems you might also encounter issues due to SELinux policies inherited from Apache processes. – Graham Dumpleton Dec 12 '16 at 23:50
  • I see, so a solution like celery would circumvent these issues as the process is called independent of Apache2? Thank you so much for your time! – Furbeenator Dec 12 '16 at 23:52

0 Answers0