FastCGI scripts

Rafael Villar Burke pachi at rvburke.com
Tue Feb 27 23:20:40 UTC 2007


Following the steps that Brendan walked before, I've changed the 
existing hgweb.cgi and hgwebdir.cgi scripts to use the Flup package and 
provide that way a FastCGI implementation of those scripts.
The Flups module can be obtained from http://trac.saddi.com/flup
Please, report if these work for you.

Regards,

Rafael Villar Burke

=== hgweb.fcgi ===
#!/usr/bin/env python
#
# An example FastCGI script to use hgweb. Edit as necessary
# The Flup module, which provides the FastCGI server, and is required
# to run this script, can be obtained from http://trac.saddi.com/flup

## example Apache configuration, for httpd.conf
# <VirtualHost *>
#         ServerName www.yourserver.com
#         ServerAlias yourserver.com
#         # Uncomment the next line when you want to use Suexec
#         ##SuexecUserGroup youruser yourgroup
#
#         AddType fastcgi-script .fcg
#         ScriptAlias / /path/to/hgweb.fcg/
# </VirtualHost>

# send python tracebacks to the browser if an error occurs:
import cgitb
cgitb.enable()

# adjust python path if not a system-wide install:
#import sys
#sys.path.insert(0, "/path/to/python/lib")

# If you'd like to serve pages with UTF-8 instead of your default
# locale charset, you can do so by uncommenting the following lines.
# Note that this will cause your .hgrc files to be interpreted in
# UTF-8 and all your repo files to be displayed using UTF-8.
#
#import os
#os.environ["HGENCODING"] = "UTF-8"

from mercurial.hgweb.hgweb_mod import hgweb
from mercurial.hgweb.request import wsgiapplication
import flup.server.fcgi.WSGIServer as wsgifcgi

def make_web_app():
    return hgweb("/path/to/repo", "repository name")

wsgifcgi(wsgiapplication(make_web_app)).run()

=== hgwebdir.fcgi ===

#!/usr/bin/env python
#
# An example FastCGI script to export multiple hgweb repos. Edit as 
necessary
# The Flup module, which provides the FastCGI server, and is required
# to run this script, can be obtained from http://trac.saddi.com/flup

## example Apache configuration, for httpd.conf
# <VirtualHost *>
#         ServerName www.yourserver.com
#         ServerAlias yourserver.com
#         # Uncomment the next line when you want to use Suexec
#         ##SuexecUserGroup youruser yourgroup
#
#         AddType fastcgi-script .fcg
#         ScriptAlias / /path/to/hgwebdir.fcg/
# </VirtualHost>

# send python tracebacks to the browser if an error occurs:
import cgitb
cgitb.enable()

# adjust python path if not a system-wide install:
#import sys
#sys.path.insert(0, "/path/to/python/lib")

# If you'd like to serve pages with UTF-8 instead of your default
# locale charset, you can do so by uncommenting the following lines.
# Note that this will cause your .hgrc files to be interpreted in
# UTF-8 and all your repo files to be displayed using UTF-8.
#
#import os
#os.environ["HGENCODING"] = "UTF-8"

from mercurial.hgweb.hgwebdir_mod import hgwebdir
from mercurial.hgweb.request import wsgiapplication
import flup.server.fcgi.WSGIServer as wsgifcgi

# The config file looks like this.  You can have paths to individual
# repos, collections of repos in a directory tree, or both.
#
# [paths]
# virtual/path = /real/path
# virtual/path = /real/path
#
# [collections]
# /prefix/to/strip/off = /root/of/tree/full/of/repos
#
# collections example: say directory tree /foo contains repos /foo/bar,
# /foo/quux/baz.  Give this config section:
#   [collections]
#   /foo = /foo
# Then repos will list as bar and quux/baz.
#
# Alternatively you can pass a list of ('virtual/path', '/real/path') tuples
# or use a dictionary with entries like 'virtual/path': '/real/path'

def make_web_app():
    return hgwebdir("hgweb.config")

wsgifcgi(wsgiapplication(make_web_app)).run()

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: hgwebdir.fcgi
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-devel/attachments/20070228/dd12bf82/attachment.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: hgweb.fcgi
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-devel/attachments/20070228/dd12bf82/attachment-0001.ksh>


More information about the Mercurial-devel mailing list