====Mercurial====
This example install mercurial as a web service.
===Install===
apt install mercurial uwsgi-core uwsgi-plugins-all
===UWSGI===
==Test==
__Application__
foobar.py
def application(env, start_response):
start_response('200 OK', [('Content-Type','text/html')])
return [b"Hello World"]
__Server__
uwsgi --plugins http,python3 --http :9090 --wsgi-file foobar.py
__Client__
$ telnet 127.0.0.1 9090
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
HEAD / HTTP/1.0
HTTP/1.0 200 OK
Content-Type: text/html
Hello World
===Run it===
==CGI==
__/var/www/cgi-bin/hgweb.wsgi__
config = b"/var/www/repos/WWW.EXAMPLE.COM/hgweb.config"
import os
os.environ["HGENCODING"] = "UTF-8"
import cgitb; cgitb.enable()
from mercurial import demandimport; demandimport.enable()
from mercurial.hgweb import hgweb
application = hgweb(config)
==CONF==
__/var/www/repos/WWW.EXAMPLE.COM/hgweb.config__
[collections]
/var/www/repos/WWW.EXAMPLE.COM = /var/www/repos/WWW.EXAMPLE.COM
[web]
staticurl = /static/
allow_archive = gz
==RUN==
__http__
#! /bin/bash
#LOG
exec 2>&1
ulimit -l unlimited
ulimit -i unlimited
ulimit -q unlimited
ulimit -n 8192
ulimit -aH
#RUN
export TZ="UTC"
exec /bin/uwsgi --die-on-term --plugins http,python3 --http :9090 --master --processes 4 --threads 2 --uid=www-data --gid=www-data --wsgi-file /var/www/cgi-bin/hgweb.wsgi
__UWSGI__
#! /bin/bash
#LOG
exec 2>&1
ulimit -l unlimited
ulimit -i unlimited
ulimit -q unlimited
ulimit -n 8192
ulimit -aH
#RUN
export TZ="UTC"
mkdir -p /run/uwsgi
chown -R www-data:www-data /run/uwsgi
exec /bin/uwsgi --die-on-term --plugins python3 --uwsgi-socket /run/uwsgi/hgweb.sock --master --processes 4 --threads 2 --uid=www-data --gid=www-data --wsgi-file /var/www/cgi-bin/hgweb.wsgi
===NGINX===
...
location / {
uwsgi_pass unix:/run/uwsgi/hgweb.sock;
include uwsgi_params;
limit_except GET HEAD {
auth_basic "Login";
auth_basic_user_file /var/www/private/htpasswd;
}
}
location /static/ {
alias /usr/lib/python3/dist-packages/mercurial/templates/static/;
expires 30d;
}
...
===Resources===
[[https://wiki.mercurial-scm.org/PublishRepositoriesOnNginx|NGINX setup]]
[[https://uwsgi-docs.readthedocs.io/en/latest/WSGIquickstart.html|UWSGI]]