diff --git a/.gitignore b/.gitignore index 36d4adbe97..083534daf5 100644 --- a/.gitignore +++ b/.gitignore @@ -17,4 +17,6 @@ gpg_home/ /venv/ .coverage /dist/ +.idea/ +static_collected/ *egg-info* diff --git a/contrib/gunicorn/gunicorn.conf.py b/contrib/gunicorn/gunicorn.conf.py new file mode 100644 index 0000000000..7e3916f474 --- /dev/null +++ b/contrib/gunicorn/gunicorn.conf.py @@ -0,0 +1,31 @@ +# invoke gunicorn using +# 'gunicorn -c .wsgi:application +import os +import multiprocessing + +from django.conf import settings + +bind = settings.GUNICORN_BIND +workers = multiprocessing.cpu_count() * 2 + 1 + +preload_app = True + +chdir = settings.BASE_DIR + +user = settings.PROCESS_USER +group = user + +log_dir = os.path.join( + os.path.dirname(settings.BASE_DIR), 'gunicorn_logs', settings.PROCESS_NAME) +if not os.path.isdir(log_dir): + os.makedirs(log_dir) + import pwd + import grp + os.chown(log_dir, + pwd.getpwnam(user).pw_uid, + grp.getgrnam(group).gr_gid) + +accesslog = os.path.join(log_dir, 'access.log') +errorlog = os.path.join(log_dir, 'error.log') + +proc_name = settings.PROCESS_NAME \ No newline at end of file diff --git a/contrib/nginx/nginx.conf b/contrib/nginx/nginx.conf new file mode 100644 index 0000000000..dfc719ae8c --- /dev/null +++ b/contrib/nginx/nginx.conf @@ -0,0 +1,34 @@ +server { + listen 80; + server_name mayan.crossculturalconsult.com www.mayan.crossculturalconsult.com; + + access_log /var/log/nginx/mayan.crossculturalconsult.com.access.log; + error_log /var/log/nginx/mayan.crossculturalconsult.com.error.log; + root /home/mayan/production/; + + location /static/ { + alias /home/mayan/production/static_collected/; + } + + location /media/ { + alias /home/mayan/production/media/; + } + + location = /favicon.ico { + alias /home/mayan/production/media/favicon.ico; + } + + location = /robots.txt { + alias /home/mayan/production/media/robots.txt; + } + + location / { + proxy_pass http://127.0.0.1:8731; + proxy_redirect off; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + client_max_body_size 10m; + } + allow all; +} \ No newline at end of file diff --git a/contrib/upstart/service_demon.sh b/contrib/upstart/service_demon.sh new file mode 100755 index 0000000000..8d591edc3d --- /dev/null +++ b/contrib/upstart/service_demon.sh @@ -0,0 +1,10 @@ +#!/bin/bash +# Run the gunicorn service + +# Make sure we're in the right virtual env and location +source /home/mayan/.virtualenvs/production/bin/activate +source /home/mayan/.virtualenvs/production/bin/postactivate + +cd /home/mayan/production + +exec gunicorn -c /home/mayan/production/deploy/gunicorn.conf.py mayan.wsgi:application \ No newline at end of file diff --git a/contrib/upstart/upstart.conf b/contrib/upstart/upstart.conf new file mode 100644 index 0000000000..261d408b83 --- /dev/null +++ b/contrib/upstart/upstart.conf @@ -0,0 +1,10 @@ +start on started rc +stop on stopped rc + +respawn +respawn limit 3 5 + +setuid mayan +setgid mayan + +exec /home/mayan/production/deploy/production/service_demon.sh \ No newline at end of file diff --git a/mayan/config/example.py b/mayan/config/example.py deleted file mode 100644 index 0b4445d0ba..0000000000 --- a/mayan/config/example.py +++ /dev/null @@ -1,16 +0,0 @@ -import os - -from mayan.settings import * - -# Production database settings -# -# DATABASES = { -# 'default': { -# 'ENGINE': 'django.db.backends.postgresql', -# 'NAME': '', -# -# } -# } - -# Production file locations (document_storage, gpg_home, image_cache) -# SITE_ROOT = '/local/mayan_files/ diff --git a/mayan/config/__init__.py b/mayan/settings/__init__.py similarity index 100% rename from mayan/config/__init__.py rename to mayan/settings/__init__.py diff --git a/mayan/settings.py b/mayan/settings/base.py similarity index 75% rename from mayan/settings.py rename to mayan/settings/base.py index 26723ec10a..92e92876f2 100644 --- a/mayan/settings.py +++ b/mayan/settings/base.py @@ -1,5 +1,5 @@ """ -Django settings for testproject project. +Django settings for Mayan EDMS project. For more information on this file, see https://docs.djangoproject.com/en/1.6/topics/settings/ @@ -10,19 +10,15 @@ https://docs.djangoproject.com/en/1.6/ref/settings/ # Build paths inside the project like this: os.path.join(BASE_DIR, ...) import os +import sys -ugettext = lambda s: s - -BASE_DIR = os.path.abspath(os.path.dirname(__file__)) -SITE_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) +_file_path = os.path.abspath(os.path.dirname(__file__)).split('/') +BASE_DIR = SITE_ROOT = '/'.join(_file_path[0:-2]) # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/1.6/howto/deployment/checklist/ -# SECURITY WARNING: keep the secret key used in production secret! -SECRET_KEY = 'om^a(i8^6&h+umbd2%pt91cj!qu_@oztw117rgxmn(n2lp^*c!' - # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True @@ -30,11 +26,10 @@ TEMPLATE_DEBUG = True ALLOWED_HOSTS = [] - # Application definition INSTALLED_APPS = ( -# Django + #Django 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', @@ -44,7 +39,7 @@ INSTALLED_APPS = ( 'django.contrib.admindocs', 'django.contrib.comments', 'django.contrib.staticfiles', -# 3rd party + # 3rd party 'south', 'rest_framework_swagger', 'filetransfers', @@ -53,7 +48,7 @@ INSTALLED_APPS = ( 'compressor', 'rest_framework', 'solo', -# Base generic + # Base generic 'permissions', 'project_setup', 'project_tools', @@ -61,8 +56,8 @@ INSTALLED_APPS = ( 'navigation', 'lock_manager', 'web_theme', -# pagination needs to go after web_theme so that the pagination template -# if found + # pagination needs to go after web_theme so that the pagination template + # if found 'pagination', 'common', 'django_gpg', @@ -74,7 +69,7 @@ INSTALLED_APPS = ( 'scheduler', 'job_processor', 'installation', -# Mayan EDMS + # Mayan EDMS 'storage', 'app_registry', 'folders', @@ -95,8 +90,8 @@ INSTALLED_APPS = ( 'checkouts', 'bootstrap', 'registration', -# Has to be last so the other apps can register it's signals - 'signaler', + # Has to be last so the other apps can register it's signals + 'signaler' ) MIDDLEWARE_CLASSES = ( @@ -140,23 +135,15 @@ USE_L10N = True USE_TZ = True - -# Static files (CSS, JavaScript, Images) -# https://docs.djangoproject.com/en/1.6/howto/static-files/ - -STATIC_URL = '/static/' - # Custom settings section -import sys - from django.core.urlresolvers import reverse_lazy -sys.path.append(os.path.join(BASE_DIR, 'apps')) - PROJECT_TITLE = 'Mayan EDMS' PROJECT_NAME = 'mayan' +ugettext = lambda s: s + LANGUAGES = ( ('ar', ugettext('Arabic')), ('bg', ugettext('Bulgarian')), @@ -184,11 +171,13 @@ LANGUAGES = ( SITE_ID = 1 -STATIC_ROOT = os.path.join(SITE_ROOT, 'static/') +STATIC_URL = '/static/' -STATIC_URL = '/%s-static/' % PROJECT_NAME +# Custom settings section -ADMIN_MEDIA_PREFIX = STATIC_URL + 'admin/' +sys.path.append(os.path.join(BASE_DIR, 'mayan', 'apps')) + +STATIC_ROOT = os.path.join(BASE_DIR, 'static') # List of callables that know how to import templates from various sources. TEMPLATE_LOADERS = ( @@ -198,13 +187,6 @@ TEMPLATE_LOADERS = ( )), ) -TEMPLATE_DIRS = ( - # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates". - # Always use forward slashes, even on Windows. - # Don't forget to use absolute paths, not relative paths. - # os.path.join(PROJECT_ROOT, 'templates') -) - TEMPLATE_CONTEXT_PROCESSORS = ( 'django.contrib.auth.context_processors.auth', 'django.core.context_processors.i18n', @@ -216,7 +198,6 @@ TEMPLATE_CONTEXT_PROCESSORS = ( STATICFILES_FINDERS = ( 'django.contrib.staticfiles.finders.FileSystemFinder', 'django.contrib.staticfiles.finders.AppDirectoriesFinder', - # other finders.. 'compressor.finders.CompressorFinder', ) @@ -272,42 +253,3 @@ REST_FRAMEWORK = { 'rest_framework.authentication.SessionAuthentication', ) } - -try: - from settings_local import * -except ImportError: - pass - -if DEBUG: - INTERNAL_IPS = ('127.0.0.1',) - - TEMPLATE_LOADERS = ( - 'django.template.loaders.filesystem.Loader', - 'django.template.loaders.app_directories.Loader', - ) - try: - import rosetta - INSTALLED_APPS += ('rosetta',) - except ImportError: - pass - - try: - import django_extensions - INSTALLED_APPS += ('django_extensions',) - except ImportError: - pass - - try: - import debug_toolbar - # INSTALLED_APPS +=('debug_toolbar',) - except ImportError: - pass - - TEMPLATE_CONTEXT_PROCESSORS += ('django.core.context_processors.debug',) - - WSGI_AUTO_RELOAD = True - if 'debug_toolbar' in INSTALLED_APPS: - MIDDLEWARE_CLASSES += ('debug_toolbar.middleware.DebugToolbarMiddleware',) - DEBUG_TOOLBAR_CONFIG = { - 'INTERCEPT_REDIRECTS': False, - } diff --git a/mayan/settings/development.py b/mayan/settings/development.py new file mode 100644 index 0000000000..8be98105bc --- /dev/null +++ b/mayan/settings/development.py @@ -0,0 +1,30 @@ +from __future__ import absolute_import + +from .base import * + +DEBUG = True +TEMPLATE_DEBUG = DEBUG + +ALLOWED_HOSTS = ['*'] + +INTERNAL_IPS = ('127.0.0.1',) + +TEMPLATE_LOADERS = ( + 'django.template.loaders.filesystem.Loader', + 'django.template.loaders.app_directories.Loader' +) + +INSTALLED_APPS += ( + 'rosetta', + 'django_extensions', + 'debug_toolbar' +) + +# Stop debug toolbar patching! (see https://github.com/django-debug-toolbar/django-debug-toolbar/issues/524) +DEBUG_TOOLBAR_PATCH_SETTINGS = False + +TEMPLATE_CONTEXT_PROCESSORS += ('django.core.context_processors.debug',) + +WSGI_AUTO_RELOAD = True + +MIDDLEWARE_CLASSES += ('debug_toolbar.middleware.DebugToolbarMiddleware',) diff --git a/mayan/urls.py b/mayan/urls.py index a01a8486cb..013af06664 100644 --- a/mayan/urls.py +++ b/mayan/urls.py @@ -62,6 +62,12 @@ if settings.DEBUG: urlpatterns += staticfiles_urlpatterns() if 'rosetta' in settings.INSTALLED_APPS: - urlpatterns += patterns('', - url(r'^rosetta/', include('rosetta.urls'), name='rosetta'), - ) + urlpatterns += patterns( + '', + url(r'^rosetta/', include('rosetta.urls'), name='rosetta')) + + import debug_toolbar + urlpatterns += patterns( + '', + url(r'^__debug__/', include(debug_toolbar.urls))) + diff --git a/requirements.txt b/requirements.txt index ea77c2d839..c58f7cb09c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1 @@ --r requirements/production.txt +-r requirements/common.txt diff --git a/requirements/development.txt b/requirements/development.txt index 3433d95c6b..084871c086 100644 --- a/requirements/development.txt +++ b/requirements/development.txt @@ -5,3 +5,4 @@ django-extensions==1.3.8 django-rosetta==0.7.4 transifex-client==0.10 django-debug-toolbar==1.2.1 +ipython==2.1.0 diff --git a/requirements/production.txt b/requirements/production.txt deleted file mode 100644 index 2f1bacec15..0000000000 --- a/requirements/production.txt +++ /dev/null @@ -1,2 +0,0 @@ -# requirements/production.txt --r common.txt