What have you found for these years?

2009-06-04

id-img

應要求隨手寫的...
http://github.com/godfat/id-img/
要用 pacman 裝的是:

1. gcc 4.4 (結果 passenger nginx 模組 build 不起來...)
2. make
3. git
4. ruby
5. rubygems
6. imagemagick
7. nginx

要用 rubygems 裝的是:
bash-3.2$ gem list

*** LOCAL GEMS ***

daemons (1.0.10)
eventmachine (0.12.8)
quilt (0.0.3)
rack (1.0.0)
rmagick (2.9.2)
thin (1.2.2)

其他設定是:

thin listen on 127.0.0.1:9998
nginx listen on 0.0.0.0:9999

使用方法是 request uri 為 id, 要點綴 .png
例如:

/godfat.png

如果是連:

/godfat

則 nginx 會 redirect 至 /godfat.png

這樣做的理由是幫助未來做 cache, 或是直接從 nginx 出圖。
目前一律都先丟到 ruby, 檢查圖檔存在否?
不存在則建立,存在則忽略,最後都把圖檔用 X-Accel-Redirect
叫 nginx 直接丟圖出去,千萬別用 ruby 出 binary 檔,超慢。

目前圖檔大小也是寫死的,啟動關閉 script 也簡單用 shell 而已。
雖然 app-deploy 這部份是寫得滿完整的啦,但有點懶...
也還沒看 god 這邊是怎麼做 process management.

未來則是要把檔案存在否改由 nginx 檢查,
還有思考遭到攻擊時要怎麼處理... 現在亂丟字串就亂生圖 @_@
也只切了 0~f 當分類目錄,由 md5 第一碼決定。
這邊 thumbo 可以自由決定要幾位數,同樣懶得引用 thumbo...

總之就是很潦草啦,先這樣用吧

0 retries:

Post a Comment

Note: Only a member of this blog may post a comment.



All texts are licensed under CC Attribution 3.0