I would like to run my Django sitw with FastCGI.
I can successfully start the TCP server with the following command.
python manage.py runfcgi method=prefork host=127.0.0.1 \
port=3000 maxrequests=100 daemonize=true
However, if fails if I add the pidfile option in the command.
python manage.py runfcgi method=prefork host=127.0.0.1 \
port=3000 maxrequests=100 daemonize=true pidfile=/var/run/django.pid
I got no exception printed out with the second command, but the TCP server is not started.
Django version: 1.6.11
May I know what could be the problem cause this failure?
I guess the failure might be caused by permission issue. I am running the command with a standard user. However, it does not solve the problem if I am using sudo
.
Thanks for Andriy's answer, I have solved the problem. The TCP server is not started because of permission. However, by simply executing the command with sudo
will not work.
Moreover, I did try using django.pid
as the pidfile name. However, it seems that the script does not correctly resolve relative path. After changing the pidfile to a folder where current user have permission to write into with absolute path, it works!
Most likely, you has no permisson to create pidfile within /var/run/django.pid
.
You can change chmod of /var/run
, with command
sudo chmod -R 666 /var/run
or place pidfile under folder where you have write permissions, for example.
python manage.py runfcgi method=prefork host=127.0.0.1 \
port=3000 maxrequests=100 daemonize=true pidfile=$HOME/django.pid