Commit c7bafc71 authored by Alain Takoudjou's avatar Alain Takoudjou

Update wsgi support in Trac

parent 714c964e
...@@ -84,9 +84,9 @@ class Recipe(GenericBaseRecipe): ...@@ -84,9 +84,9 @@ class Recipe(GenericBaseRecipe):
shutil.rmtree(project_dir) shutil.rmtree(project_dir)
self.logger.error("Failed to initialize Trac.\nThe error was: %s" % result) self.logger.error("Failed to initialize Trac.\nThe error was: %s" % result)
return [] return []
os.mkdir(self.options['wsgi-dir'])
os.mkdir(self.options['git-dir']) os.mkdir(self.options['git-dir'])
os.mkdir(self.options['svn-dir']) os.mkdir(self.options['svn-dir'])
os.mkdir(self.options['wsgi-dir'])
os.unlink(config) os.unlink(config)
shutil.copy(self.options['trac-ini'].strip(), config) shutil.copy(self.options['trac-ini'].strip(), config)
shutil.copy(self.options['trac-wsgi'].strip(), shutil.copy(self.options['trac-wsgi'].strip(),
......
...@@ -198,7 +198,7 @@ url = ${template-httpd-conf:location}/${template-httpd-conf:filename} ...@@ -198,7 +198,7 @@ url = ${template-httpd-conf:location}/${template-httpd-conf:filename}
output = $${rootdirectory:etc}/apache.conf output = $${rootdirectory:etc}/apache.conf
document_root = $${rootdirectory:srv}/site/ document_root = $${rootdirectory:srv}/site/
wsgi_location = $${inittrac:wsgi-dir} wsgi_location = $${rootdirectory:srv}/site/apache
gitweb-static-dir = ${gitweb:location}/share/gitweb/static/ gitweb-static-dir = ${gitweb:location}/share/gitweb/static/
gitweb-script = $${gitweb-cgi:output} gitweb-script = $${gitweb-cgi:output}
git-http-backend = $${git-http-backend-cgi:output} git-http-backend = $${git-http-backend-cgi:output}
...@@ -238,10 +238,11 @@ mysql_port = $${stunnel:local-port} ...@@ -238,10 +238,11 @@ mysql_port = $${stunnel:local-port}
[trac-wsgi] [trac-wsgi]
recipe = slapos.recipe.template recipe = slapos.recipe.template
url = ${tracWsgi:location}/${tracWsgi:filename} url = ${tracWsgi:location}/${tracWsgi:filename}
output = $${directory:tracconfig}/trac-apache.wsgi output = $${directory:tracconfig}/trac.wsgi
mode = 0700 mode = 0700
htdocs = $${trac-config:project_dir} trac_env = $${trac-config:project_dir}
python_bin = ${python2.7:location}/bin/python2.7
[trac-svn-hook-script] [trac-svn-hook-script]
recipe = slapos.recipe.template recipe = slapos.recipe.template
...@@ -284,7 +285,7 @@ svn_python = ${subversion-1.9:location}/lib/svn-python ...@@ -284,7 +285,7 @@ svn_python = ${subversion-1.9:location}/lib/svn-python
recipe = slapos.recipe.template recipe = slapos.recipe.template
url = ${template-gitweb-conf:location}/${template-gitweb-conf:filename} url = ${template-gitweb-conf:location}/${template-gitweb-conf:filename}
output = $${rootdirectory:etc}/gitweb.conf output = $${rootdirectory:etc}/gitweb.conf
url-list = $${trac-config:project_url}/git git://[$${slap-network-information:global-ipv6}] url-list = $${trac-config:project_url}/git http://[$${slap-network-information:global-ipv6}]:8080/git git://[$${slap-network-information:global-ipv6}]
base-directory = $${trac-config:project_dir}/git base-directory = $${trac-config:project_dir}/git
[gitweb-cgi] [gitweb-cgi]
...@@ -356,7 +357,6 @@ user-list = $${slap-parameter:trac-user-list} ...@@ -356,7 +357,6 @@ user-list = $${slap-parameter:trac-user-list}
recipe = slapos.cookbook:wrapper recipe = slapos.cookbook:wrapper
command-line = ${apache:location}/bin/httpd -DFOREGROUND -f "$${httpd-conf:output}" command-line = ${apache:location}/bin/httpd -DFOREGROUND -f "$${httpd-conf:output}"
environment = PYTHONPATH=${subversion-1.9:location}/lib/svn-python:$${inittrac:python_path} environment = PYTHONPATH=${subversion-1.9:location}/lib/svn-python:$${inittrac:python_path}
PATH=${python2.7:location}/bin:%(PATH)s
wrapper-path = $${basedirectory:services}/httpd wrapper-path = $${basedirectory:services}/httpd
wait-for-files = $${inittrac:file-status} wait-for-files = $${inittrac:file-status}
......
...@@ -5,10 +5,10 @@ develop = ...@@ -5,10 +5,10 @@ develop =
# ${trac-plugins-egg:location}/accountmanager # ${trac-plugins-egg:location}/accountmanager
parts = parts =
apache-wsgi
slapos-cookbook slapos-cookbook
gitweb gitweb
subversion-1.9 subversion-1.9
apache-wsgi
instance-egg instance-egg
instance instance
instance-trac instance-trac
...@@ -29,8 +29,9 @@ parts = ...@@ -29,8 +29,9 @@ parts =
extends = extends =
../../stack/slapos.cfg ../../stack/slapos.cfg
../../component/python-2.7/buildout.cfg
../../component/apache/buildout.cfg ../../component/apache/buildout.cfg
../../component/python-2.7/buildout.cfg
../../component/apache-wsgi/buildout.cfg
../../component/logrotate/buildout.cfg ../../component/logrotate/buildout.cfg
../../component/subversion/buildout.cfg ../../component/subversion/buildout.cfg
../../component/gzip/buildout.cfg ../../component/gzip/buildout.cfg
...@@ -39,7 +40,6 @@ extends = ...@@ -39,7 +40,6 @@ extends =
../../component/stunnel/buildout.cfg ../../component/stunnel/buildout.cfg
../../component/lxml-python/buildout.cfg ../../component/lxml-python/buildout.cfg
../../component/mysql-python/buildout.cfg ../../component/mysql-python/buildout.cfg
../../component/apache-wsgi/buildout.cfg
../../component/git/buildout.cfg ../../component/git/buildout.cfg
../../component/pwgen/buildout.cfg ../../component/pwgen/buildout.cfg
../../component/shellinabox/buildout.cfg ../../component/shellinabox/buildout.cfg
...@@ -89,7 +89,7 @@ md5sum = bc6ed91a1862a10af661713aa0691848 ...@@ -89,7 +89,7 @@ md5sum = bc6ed91a1862a10af661713aa0691848
recipe = slapos.recipe.template recipe = slapos.recipe.template
url = ${:_profile_base_location_}/instance-trac.cfg url = ${:_profile_base_location_}/instance-trac.cfg
output = ${buildout:directory}/template-trac.cfg output = ${buildout:directory}/template-trac.cfg
md5sum = a29c55056b5ce5a7409b14c54cfc00ad md5sum = 2ffa830873895fd4a014bf038119ff82
mode = 0644 mode = 0644
[instance-mariadb] [instance-mariadb]
...@@ -113,7 +113,7 @@ md5sum = 10286b368b9b6eacae2cdd6caf362759 ...@@ -113,7 +113,7 @@ md5sum = 10286b368b9b6eacae2cdd6caf362759
[tracWsgi] [tracWsgi]
<= template-download <= template-download
filename = trac.wsgi.in filename = trac.wsgi.in
md5sum = 622ca33ed7299409afec43bb79e4c7e9 md5sum = 5226978477d3336f21f0d8684d23a55a
[trac-svn-hook] [trac-svn-hook]
<= template-download <= template-download
...@@ -138,7 +138,7 @@ md5sum = 7ec8822bd5676c3506f079e33ed9f771 ...@@ -138,7 +138,7 @@ md5sum = 7ec8822bd5676c3506f079e33ed9f771
[template-httpd-conf] [template-httpd-conf]
<= template-download <= template-download
filename = apache.in filename = apache.in
md5sum = be3418e3053ec7f74a3df21830a7edc0 md5sum = 452ff6c77211e312be0227155a83931c
[template-gitweb-cgi] [template-gitweb-cgi]
<= template-download <= template-download
......
...@@ -15,6 +15,8 @@ LogLevel warn ...@@ -15,6 +15,8 @@ LogLevel warn
LogFormat "%h %{REMOTE_USER}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined LogFormat "%h %{REMOTE_USER}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %{REMOTE_USER}i %l %u %t \"%r\" %>s %b" common LogFormat "%h %{REMOTE_USER}i %l %u %t \"%r\" %>s %b" common
CustomLog "${:access_log}" common CustomLog "${:access_log}" common
ScriptSock "${:cgid-sock}"
SetEnv REMOTE_USER=$REDIRECT_REMOTE_USER
# Directory protection # Directory protection
<Directory /> <Directory />
...@@ -50,9 +52,6 @@ WSGIScriptAlias / ${:wsgi_location}/trac.wsgi ...@@ -50,9 +52,6 @@ WSGIScriptAlias / ${:wsgi_location}/trac.wsgi
</LimitExcept> </LimitExcept>
</Location> </Location>
ScriptSock "${:cgid-sock}"
SetEnv REMOTE_USER=$REDIRECT_REMOTE_USER
Alias "/static/" "${:gitweb-static-dir}" Alias "/static/" "${:gitweb-static-dir}"
<Directory "${:gitweb-static-dir}"> <Directory "${:gitweb-static-dir}">
Options FollowSymLinks Options FollowSymLinks
......
import sys #!${:python_bin}
sys.stdout = sys.stderr # -*- coding: utf-8 -*-
import os import os
os.environ['TRAC_ENV'] = '${:htdocs}'
os.environ['PYTHON_EGG_CACHE'] = '${:htdocs}/eggs'
import trac.web.main
application = trac.web.main.dispatch_request def application(environ, start_request):
\ No newline at end of file if not 'trac.env_parent_dir' in environ:
environ.setdefault('trac.env_path', '${:trac_env}')
if 'PYTHON_EGG_CACHE' in environ:
os.environ['PYTHON_EGG_CACHE'] = environ['PYTHON_EGG_CACHE']
elif 'trac.env_path' in environ:
os.environ['PYTHON_EGG_CACHE'] = \
os.path.join(environ['trac.env_path'], '.egg-cache')
elif 'trac.env_parent_dir' in environ:
os.environ['PYTHON_EGG_CACHE'] = \
os.path.join(environ['trac.env_parent_dir'], '.egg-cache')
from trac.web.main import dispatch_request
return dispatch_request(environ, start_request)
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment