Permalink
Browse files

Merge branch 'master' of github.com:mozilla/secret-squirrel

  • Loading branch information...
2 parents 86340d6 + 3392d7f commit 7d0560a3a056f27490c539b9d445662044f56aab @ozten ozten committed Nov 24, 2010
Showing with 85 additions and 21 deletions.
  1. +28 −0 bin/update_staging.sh
  2. +19 −6 manage.py
  3. +5 −6 settings.py
  4. +33 −9 wsgi/squirrel.wsgi
View
@@ -0,0 +1,28 @@
+#!/bin/bash
+
+# Update script for staging server. Takes care of updating code repo, vendor
+# dir, and running DB migrations.
+
+HERE=`dirname $0`
+GIT=`which git`
+PYTHON=`which python2.6`
+
+pushd "$HERE/../" > /dev/null
+
+# pull actual code
+$GIT pull -q origin master
+$GIT submodule update --init
+
+# pull vendor repo
+pushd vendor > /dev/null
+$GIT pull -q origin master
+$GIT submodule update --init
+popd > /dev/null
+
+# Run database migrations.
+#$PYTHON vendor/src/schematic/schematic migrations/
+
+# Minify assets.
+#$PYTHON manage.py compress_assets
+
+popd > /dev/null
View
@@ -3,20 +3,33 @@
import site
import sys
-from django.core.management import execute_manager, setup_environ
-
ROOT = os.path.dirname(os.path.abspath(__file__))
+
path = lambda *a: os.path.join(ROOT, *a)
+prev_sys_path = list(sys.path)
+
site.addsitedir(path('apps'))
-#site.addsitedir(path('lib'))
+site.addsitedir(path('lib'))
+site.addsitedir(path('vendor'))
+
+# Move the new items to the front of sys.path. (via virtualenv)
+new_sys_path = []
+for item in list(sys.path):
+ if item not in prev_sys_path:
+ new_sys_path.append(item)
+ sys.path.remove(item)
+sys.path[:0] = new_sys_path
+
+# No third-party imports until we've added all our sitedirs!
+from django.core.management import execute_manager, setup_environ
try:
import settings_local as settings
except ImportError:
try:
- import settings # Assumed to be in the same directory.
+ import settings
except ImportError:
import sys
sys.stderr.write(
@@ -25,13 +38,13 @@
" Please come back and try again later.")
raise
-# The first thing execute_manager does is call `setup_environ`. Logging config
+# The first thing execute_manager does is call `setup_environ`. Logging config
# needs to access settings, so we'll setup the environ early.
setup_environ(settings)
# Import for side-effect: configures our logging handlers.
+# pylint: disable-msg=W0611
import log_settings
-
if __name__ == "__main__":
execute_manager(settings)
View
@@ -25,11 +25,11 @@
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
- 'NAME': 'squirrel', # Or path to database file if using sqlite3.
- 'USER': '', # Not used with sqlite3.
- 'PASSWORD': '', # Not used with sqlite3.
- 'HOST': '', # Set to empty string for localhost. Not used with sqlite3.
- 'PORT': '', # Set to empty string for default. Not used with sqlite3.
+ 'NAME': 'squirrel',
+ 'USER': '',
+ 'PASSWORD': '',
+ 'HOST': '',
+ 'PORT': '',
'OPTIONS': {'init_command': 'SET storage_engine=InnoDB'},
'TEST_CHARSET': 'utf8',
'TEST_COLLATION': 'utf8_general_ci',
@@ -137,7 +137,6 @@ def JINJA_CONFIG():
'django.contrib.messages',
'cas_provider',
- 'registration',
'sso',
'users',
)
View
@@ -1,16 +1,40 @@
import os
import site
+from datetime import datetime
-import django.core.handlers.wsgi
+os.environ["CELERY_LOADER"] = "django"
+
+# Remember when mod_wsgi loaded this file so we can track it in nagios.
+wsgi_loaded = datetime.now()
-# Add the parent dir to the python path so we can import manage
+# Add the main dir to the python path so we can import manage.
wsgidir = os.path.dirname(__file__)
-site.addsitedir(os.path.abspath(os.path.join(wsgidir, '../../')))
+site.addsitedir(os.path.abspath(os.path.join(wsgidir, '../')))
+
+# manage adds /apps, /lib, and /vendor to the Python path.
+import manage
+
+import django.conf
+import django.core.handlers.wsgi
+import django.core.management
+import django.utils
+
+# Do validate and activate translations like using `./manage.py runserver`.
+# http://blog.dscpl.com.au/2010/03/improved-wsgi-script-for-use-with.html
+utility = django.core.management.ManagementUtility()
+command = utility.fetch_command('runserver')
+command.validate()
+
+# This is what mod_wsgi runs.
+django_app = django.core.handlers.wsgi.WSGIHandler()
+
+def application(env, start_response):
+ env['wsgi.loaded'] = wsgi_loaded
+ return django_app(env, start_response)
-# manage.py adds the `apps` and `lib` directories to the path
-ROOT = os.path.abspath(os.path.join(wsgidir, '../'))
-ROOT_PACKAGE = os.path.basename(ROOT)
-__import__('%s.manage' % ROOT_PACKAGE)
+# Uncomment this to figure out what's going on with the mod_wsgi environment.
+# def application(env, start_response):
+# start_response('200 OK', [('Content-Type', 'text/plain')])
+# return '\n'.join('%r: %r' % item for item in sorted(env.items()))
-# for mod-wsgi
-application = django.core.handlers.wsgi.WSGIHandler()
+# vim: ft=python

0 comments on commit 7d0560a

Please sign in to comment.