ssk’s posterous

ssk’s posterous

Jun 18 / 12:46am

ソフト/Bug Tracking/trac/MercurialPlugin - discypus

by ssk

メモ: 2008-10-24

HgWebDirStepByStep - Mercurial を見ながら、mod_wsgi経由の閲覧の設定をやってみた。

環境はDebian 4.0, Apache/2.2.3 (Debian) DAV/2 SVN/1.4.2 mod_python/3.2.10 Python/2.4.4 mod_ssl/2.2.3 OpenSSL/0.9.8c mod_wsgi/2.3

閲覧だけ、認証無し、ならこんな感じか。 [collections]で楽しようと思ったけどいまいちconfigの動作がわからんので[paths]でリポジトリを一個ずつ指定した。

/var/www/wsgi/hgwebdir.wsgi:

from mercurial.hgweb.hgweb_mod import hgweb
from mercurial.hgweb.hgwebdir_mod import hgwebdir

CONFIG = '/var/hg/public.config'
application = hgwebdir(CONFIG)

/var/hg/config:

#[collections]
#hgsandbox = /var/hg/hgsandbox # リポジトリhgsandboxのURLがhttp://localhost/hg/var/hg/hgsandboxになる。
# /var/hg/hgsandbox = /var/hg/hgsandbox  # 見つからなくなる
# hgsandbox = hgsandbox   # 500 Internal Server Error: OSError: [Errno 2] No such file or directory: 'hgsandbox'

[paths]
hgsandbox = /var/hg/hgsandbox

/etc/apache2/sites-available/trac:

WSGIScriptAlias /hg /var/www/wsgi/hgwebdir.wsgi

既存の WSGIScriptAlias は消していいのかな

Filed under  //  apache   mercurial   wsgi  

Comments (0)

Jun 17 / 4:13am

HgWebDirStepByStep - Mercurial

by ssk

8.1.3. Configuring Apache with mod_wsgi

Using mod_wsgi is recommended over using mod_python. It's one of the faster and more efficient ways of serving hgweb(dir).

You can use the hgwebdir.wsgi script (it lives where other Mercurial scripts live, and works with Mercurial 1.0 and later), which references a hgwebdir.conf file in the CONFIG variable:

 

from mercurial.hgweb.hgweb_mod import hgweb
from mercurial.hgweb.hgwebdir_mod import hgwebdir

CONFIG = '/var/hg/public.config'
application = hgwebdir(CONFIG)

This is really an ordinary Python module, but it uses a wsgi extension to make it clear what its use is.

You then need to add this to your httpd.conf (or the vhost config):

 

WSGIScriptAlias / /var/hg/script/public.wsgi
<Directory /var/hg/script>
Order deny,allow
Allow from all
</Directory>

hg 用の WSGIScriptAlias を作らないとダメ

Filed under  //  mercurial   wsgi  

Comments (0)

Jun 17 / 4:06am

ApplicationIssues - modwsgi - Common problems with WSGI applications. - Google Code

by ssk

In order to highlight non portable WSGI application components which try and read from or otherwise use standard input, mod_wsgi will replace sys.stdin with an object which will raise an exception when any attempt is made to read from standard input or otherwise manipulate or reference the object.

IOError: sys.stdin access restricted by mod_wsgi

This restriction on standard input will however prevent the use of interactive debuggers for Python such as pdb. It can also interfere with Python modules which use the isatty() method of sys.stdin to determine whether an application is being run within an interactive session.

If it is required to be able to run such debuggers or other code which requires interactive input, the restriction on using standard input can be removed using a configuration directive.

WSGIRestrictStdin Off

This configuration directive must appear at global scope within the Apache configuration file outside of any VirtualHost container directives. It will remove the restriction on using standard input from all Python sub interpreters that mod_wsgi creates. There is no way using the configuration directive to remove the restriction from only one Python sub interpreter.

virtualhost には書けないのでグローバルな場所に書け、とのこと。
でも他の wsgi アプリにも影響出るのが難

Filed under  //  wsgi  

Comments (0)