やったーmod_vimできたよー

Vim scriptはウェブアプリケーション記述言語やったんやー

Plack とかよくわかんないのでさくっと Apache で使えるようにしてみました。

mod_vim

httpd.conf はこんな感じ

LoadModule vim_module mod_vim.so
DocumentRoot .

Listen 8080

PidFile /tmp/pid
LockFile /tmp/lock
ErrorLog /tmp/error_log

VimDisplay :0
VimVersion 7.2
VimEncoding UTF-8

<Location />
    SetHandler vim
    VimExpr vimplack#handle(@@)
</Location>

ビルド方法は、まあ README に書いておけよって感じですが

make top_builddir=/usr/share/apache2/build

みたいにしてください、apr-json が別途必要です。

mattnさんのサンプルはこんな感じに動いています。

f:id:moriyoshi:20120209193608p:image

% ab -n 500 -c 20 http://localhost:8080/
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking localhost (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Finished 500 requests


Server Software:        Apache/2.2.20
Server Hostname:        localhost
Server Port:            8080

Document Path:          /
Document Length:        348 bytes

Concurrency Level:      20
Time taken for tests:   0.587 seconds
Complete requests:      500
Failed requests:        0
Write errors:           0
Total transferred:      246500 bytes
HTML transferred:       174000 bytes
Requests per second:    851.90 [#/sec] (mean)
Time per request:       23.477 [ms] (mean)
Time per request:       1.174 [ms] (mean, across all concurrent requests)
Transfer rate:          410.14 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0   22  14.0     20     229
Processing:     0    1   3.4      0      31
Waiting:        0    1   3.4      0      31
Total:          4   23  14.1     21     248

Percentage of the requests served within a certain time (ms)
  50%     21
  66%     22
  75%     23
  80%     25
  90%     28
  95%     32
  98%     52
  99%     98
 100%    248 (longest request)

Enjoy!