Nginx – django fcgi – call a management command with subprocess.Popen

djangofcginginx

I'm using an app called django-chronograph. It has a code of line which works in my dev environment and does not work in production:

p = subprocess.Popen(['python', get_manage_py(), 'run_job', str(self.pk)])

This line crashes in production with: unknown command run_job
Whereas when I run directly from command line: manage.py run_job
It works fine.

Interestingly it worked once when we exchanged 'python' with 'usr/bin/python'.
then we restarted the server once more and it was back to old behaviour.

Thus it seems as we have a python path issue.
I'm not the guy who is running the server, its my app that should run and it would be great to get some help here. Attention: I'm a total noob regarding server-administration..

server environment:
NGINX with FCGI-Daemon
FCGI in prefork-mode

Best Answer

Yeah, uh... don't do that.

django.core.management.call_command('run_job', str(self.pk))