forked from thomasd57/django-1and1
-
Notifications
You must be signed in to change notification settings - Fork 7
/
application.fcgi
executable file
·29 lines (22 loc) · 994 Bytes
/
application.fcgi
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
#!/path/to/your/htdocs/python_files/venv/bin/python
import os
import sys
import traceback
home = '/path/to/your/htdocs'
try:
os.environ['VIRTUAL_ENV'] = os.path.join(home, 'python_files/venv/bin')
os.environ['PATH'] = os.environ['VIRTUAL_ENV'] + ':' + os.environ['PATH']
project = os.path.join(home, 'your_site')
# Add a custom Python path.
sys.path.insert(0, project)
# Switch to the directory of your project.
os.chdir(project)
# Set the DJANGO_SETTINGS_MODULE environment variable.
os.environ['DJANGO_SETTINGS_MODULE'] = "your_site.settings"
from django_fastcgi.servers.fastcgi import runfastcgi
from django.core.servers.basehttp import get_internal_wsgi_application
wsgi_application = get_internal_wsgi_application()
runfastcgi(wsgi_application, method="prefork", daemonize="false", minspare=1, maxspare=1, maxchildren=1)
except:
with open(os.path.join(home, 'tmp/error.log'), 'w') as fp:
traceback.print_exc(file = fp)