Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
tools:hg [2024/07/15 17:40] darrontools:hg [2024/07/16 23:26] (current) darron
Line 1: Line 1:
-=====Mercurial=====+====Mercurial==== 
 + 
 +This example install mercurial as a web service. 
 + 
 +===Install===
  
 <code> <code>
Line 5: Line 9:
 </code> </code>
  
-====Resources====+ 
 +===UWSGI==
 + 
 +==Test== 
 + 
 +__Application__ 
 + 
 +foobar.py 
 +<code> 
 +def application(env, start_response): 
 +    start_response('200 OK', [('Content-Type','text/html')]) 
 +    return [b"Hello World"
 +</code> 
 + 
 +__Server__ 
 +<code> 
 +uwsgi --plugins http,python3 --http :9090 --wsgi-file foobar.py 
 +</code> 
 + 
 +__Client__ 
 +<code> 
 +$ 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 
 +</code> 
 + 
 +===Run it=== 
 + 
 +==CGI== 
 + 
 +__/var/www/cgi-bin/hgweb.wsgi__ 
 + 
 +<code> 
 +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) 
 +</code> 
 + 
 +==CONF== 
 + 
 +__/var/www/repos/WWW.EXAMPLE.COM/hgweb.config__ 
 +<code> 
 +[collections] 
 +/var/www/repos/WWW.EXAMPLE.COM = /var/www/repos/WWW.EXAMPLE.COM 
 + 
 +[web] 
 +staticurl = /static/ 
 +allow_archive = gz 
 +</code> 
 + 
 +==RUN== 
 + 
 +__http__ 
 +<code> 
 +#! /bin/bash 
 + 
 +#LOG 
 +exec 2>&
 +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 
 +</code> 
 + 
 + 
 +__UWSGI__ 
 + 
 +<code> 
 +#! /bin/bash 
 + 
 +#LOG 
 +exec 2>&
 +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 
 +</code> 
 +===NGINX=== 
 + 
 +<code> 
 +... 
 +        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; 
 +        } 
 +... 
 +</code> 
 + 
 +===Resources===
  
 [[https://wiki.mercurial-scm.org/PublishRepositoriesOnNginx|NGINX setup]] [[https://wiki.mercurial-scm.org/PublishRepositoriesOnNginx|NGINX setup]]
  
 +[[https://uwsgi-docs.readthedocs.io/en/latest/WSGIquickstart.html|UWSGI]]