
I made a quick hack to be able to server mercurial repositories with SCGI served by Cherokee. I guess it would also work with other web servers, but I haven't tested it.
Requirements
- Cherokee Web Server
- Mercurial
- python-flup
If you are using Debian it's as simple as
# aptitude install cherokee
# aptitude install mercurial
# aptitude install python-flup
Installing the Mercurial SCGI server
Fetch the Mercurial SCGI server here and copy it to a directory in your webserver. Change the owner and group if required and add the executable bit using chmod
Configuration options
The Mercurial SCGI server can be configured by using the following options:
- HGWEBCONFIGPATH - Defines the path where the hgweb.config is located. If not defined, the default will be the directory where the Mercurial SCGI server file (hgwebdir-scgi) file is located
- SCGIPORT - Defines the port in wich the SCGI server will listen. Defaults to 4000
- BINDADDRESS - Defines the name/ip in which the SCGI server will listen. Defaults to localhost.
The format and contents of the hgweb.config file are documented here
Configuring Cherokee
Once you have the basics installed it's time to setup cherokee to use the SCGI handler to server the mercurial repositories.
Start your cherokee-admin and login the admin web page.
In this case we will run the SCGI server in the same machine and we will make Cherokee responsible for starting and stopping the server. For that you'll have to create a new information source. Click in Sources (top panel toolbar) and then add a new information source with localhost:4000 in the Connection field.
Change the Type from Remote Server to Local Interpreter. Fill the interpreter field with the path and name of the Mercurial SCGI server (for example /usr/local/bin/hgwebdir-scgi)
Uncheck Inherit Environment and then add a HGWEBCONFIGPATH variable with the directory where hgweb.config is located as value (for example /var/hg)
Now go to vServers to create a new rule to redirect requests to the SCGI server.
Click on the Behavior tab and then in Rule management use the Directory Rule Type and set it to the desired path (example /hgrepos). Then click on the Handler tab and select the SCGI handler.
Select a Balancer Policy and then choose the previously created Information Source
Click on Save and then choose Graceful restart and voila you'll be serving your mercurial repositories using SCGI.
As an extra you can add a new rule to serve the static content using the high performance Static content handler.
Enjoy!