星期一, 10月 29, 2007

[tips] using flup as trac's default fastcgi backend. (with lighttpd)

I've found trac's fastcgi backend simply out-dated. I thinks it's direct copied from an old flup source, and since then flup really updates a lot, I've already use thread pool techniques everywhere in our web applications/frameworks for a while, so current trac's fastcgi backend implement just so out-dated and looks wierd when I installed it, really.

But thanks there's WSGI to save us ! I could just replace the fastcgi backend to flup-0.5 (latest, and author claims it maybe final version of flup) and SAVE MEMORY !

and it's simple too,
just install the flup package, and edit your old trac.fcgi / lighttpd's settings.

trac.fcgi:


try:
import pkg_resources

from trac import __version__ as VERSION
from trac.web.main import dispatch_request

from flup.server.fcgi import WSGIServer
WSGIServer(dispatch_request,maxSpare=100,minSpare=100,maxThreads=100).run()

except SystemExit:
raise
except Exception, e:
print 'Content-Type: text/plain\r\n\r\n',
print 'Oops...'
print
print 'Trac detected an internal error:'
print
print e
print
import traceback
import StringIO
tb = StringIO.StringIO()
traceback.print_exc(file=tb)
print tb.getvalue()


you can change the line which specify
maxSpare,minSpare,maxThreads,I use 100,
you should use less than 381 if you're using
python 2.4 (you'll hit stack limit at least on i386-linux) however if you're using python 2.5 you can change stack size via thread.stack_size,
though I don't think anyone would need that high concurrency (who knows?!).

below's also a sample setting in lighttpd.conf,

what really matters here is to remember add a
"max-procs" => 1
line in it, since we've already using thread pools technique, forking another process seems redundant (and WASTE memory).


fastcgi.server += ("/sandbox" =>
("sandbox" =>
("socket" => "/tmp/trac-sandbox.sock", #need to change for each
"bin-path" => "/var/trac/cgi-bin/trac.fcgi",
"max-procs" => 1, #default 4
"check-local" => "disable",
"bin-environment" =>
("TRAC_ENV" => "/var/trac/sandbox")
)
)
)


oh, btw I'm using trac-0.11dev, but I think any version below 0.11 which implement WSGI should also works.

星期日, 10月 21, 2007

[funny] Richard Stallman (RMS) 被忍者攻擊.

來自 Slashdot 的報導:

耶魯大學政治聯盟(Yale
Political Union, YPU,美國最古老的學生政治組織)的學生

仿效著名geek漫畫xkcd, 在耶魯一場Stallman對於DRM(Digital restrictions management)議題的演講裡, 對Stallman進行(玩笑似的)攻擊.




Richard Stallman主要在耶魯大學講述的議題為DRM,
RMS 認為現在大型商業公司(Apple,Microsoft,Sony)推動的DRM(數位著作權管理)是非法的,

常用的DRM限制包括:

* 必須在指定電腦或播放機才能播放
* 必須在特定的日期前才能播放
* 播放的次數
* 傳輸到播放機的次數
* 燒錄到光碟的次數
* 以上限制的混合
(引用自Wikipedia的DRM條目)

而GPLv3也可說是RichardStallman對DRM全面宣戰的GPL改進條款.

耶魯大學政治聯盟在RMS演講之後, 進行對 "DRM是非法的"這個議題的投票, 以33對20票通過.

不論我喜不喜歡GPL, RMS無疑是自由軟體界真正的鬥士,
他對於他眼中的惡向來從不讓步,
沒有GPL與FSF, 今日的自由軟體絕不能如此蓬勃.
而這樣具有風骨的人物跟信念堅持, 不論我是否同意他的論點, 都是讓我值得尊敬的.