- Author:
- nipuL
- Posted:
- March 27, 2008
- Language:
- Python
- Version:
- .96
- Tags:
- management fcgi
- Score:
- 0 (after 0 ratings)
Add fcgi to settings.INSTALLED_APPS then you can start and stop FCGI through manage.py
python manage.py startfcgi
python manage.py stopfcgi
In settings define runfcgi arguments using FCGI_* in settings
For example:
FCGI_SOCKET='/var/tmp/project.sock' FCGI_PIDFILE='/var/run/project.pid'
One of FCGI_SOCKET or FCGI_HOST/FCGI_PORT will need to be defined, but if you forget they will error out.
FCGI_PIDFILE is required to be defined to allow the process to be terminated.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | # fcgi/management/commands/startfcgi.py
from django.core.management.base import NoArgsCommand
from django.core.management.commands import runfcgi
class Command(NoArgsCommand):
def handle_noargs(self, **options):
args = self.get_args()
if isinstance(args, str):
return args
return runfcgi.Command().execute(*args, **options)
def get_args(self):
from django.conf import settings
if not getattr(settings, 'FCGI_PIDFILE', None):
return 'FCGI_PIDFILE must be specified in your settings'
return [
'%s=%s'%(attr.split('_')[1].lower(), getattr(settings, attr))
for attr in dir(settings) if attr.startswith('FCGI_')
]
# fcgi/management/commands/stopfcgi.py
from django.core.management.base import NoArgsCommand
class Command(NoArgsCommand):
def handle_noargs(self, **options):
import os
from django.conf import settings
pidfile = getattr(settings, 'FCGI_PIDFILE', None)
if not pidfile:
return 'FCGI_PIDFILE must be specified in settings'
os.kill(int(open(pidfile).read()), 15)
|
More like this
- Serialize a model instance by chriswedgwood 1 week, 2 days ago
- Automatically setup raw_id_fields ForeignKey & OneToOneField by agusmakmun 9 months, 1 week ago
- Crispy Form by sourabhsinha396 10 months ago
- ReadOnlySelect by mkoistinen 10 months, 2 weeks ago
- Verify events sent to your webhook endpoints by santos22 11 months, 2 weeks ago
Comments
Please login first before commenting.