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 19:53] – [Test] darrontools:hg [2024/07/16 23:26] (current) darron
Line 1: Line 1:
-=====Mercurial=====+====Mercurial====
  
-====Install====+This example install mercurial as a web service. 
 + 
 +===Install===
  
 <code> <code>
Line 8: Line 10:
  
  
-====UWSGI====+===UWSGI===
  
-===Test===+==Test==
  
-==Application==+__Application__
  
-__foobar.py__+foobar.py
 <code> <code>
 def application(env, start_response): def application(env, start_response):
Line 21: Line 23:
 </code> </code>
  
-==Server==+__Server__
 <code> <code>
 uwsgi --plugins http,python3 --http :9090 --wsgi-file foobar.py uwsgi --plugins http,python3 --http :9090 --wsgi-file foobar.py
 </code> </code>
  
-==Client==+__Client__
 <code> <code>
 $ telnet 127.0.0.1 9090 $ telnet 127.0.0.1 9090
Line 40: Line 42:
 </code> </code>
  
-====Resources====+===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]] [[https://uwsgi-docs.readthedocs.io/en/latest/WSGIquickstart.html|UWSGI]]