Created
October 28, 2010 17:36
-
-
Save rizumu/651880 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff -r 832f7d4a6f4c deploy/gunicorn_conf.py | |
--- a/deploy/gunicorn_conf.py Thu Oct 28 14:29:39 2010 +0200 | |
+++ b/deploy/gunicorn_conf.py Thu Oct 28 13:36:19 2010 -0400 | |
@@ -1,16 +1,31 @@ | |
import sys | |
-from os import sysconf | |
+import os | |
from pkg_resources import load_entry_point | |
def numCPUs(default=1): | |
- try: | |
- return sysconf('SC_NPROCESSORS_ONLN') | |
- except (AttributeError, ValueError): | |
- return default | |
+ if not hasattr(os, "sysconf"): | |
+ raise RuntimeError("No sysconf detected.") | |
+ return os.sysconf("SC_NPROCESSORS_ONLN") | |
+bind = "0.0.0.0:8000" | |
workers = numCPUs() * 2 + 1 | |
+# redirect sys.stdout to sys.stderr for bad libraries like geopy that uses | |
+# print statements for optional import exceptions. | |
+sys.stdout = sys.stderr | |
+ | |
+from os.path import abspath, dirname, join | |
+sys.path.insert(0, abspath(join(dirname(__file__), "../../"))) | |
+ | |
+from site import addsitedir | |
+addsitedir("/home/comunidad/.virtualenvs/comunidad/lib/python2.6/site-packages") | |
+ | |
+from django.conf import settings | |
+os.environ["DJANGO_SETTINGS_MODULE"] = "comunidad.settings" | |
+ | |
# if run as a script, make it equivalent to "gunicorn_django -c THIS_FILE [OPTIONS]" | |
if __name__ == '__main__': | |
+ sys.path.insert(0, join(settings.PROJECT_ROOT, "apps")) | |
+ sys.path.insert(0, join(settings.PROJECT_ROOT, "site-packages")) | |
sys.argv[:0] = ['gunicorn_django', '-c'] | |
load_entry_point('gunicorn', 'console_scripts', 'gunicorn_django')() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment