83's

Top > Tags > mongrel

mongrel

タイトル一覧を表示 | 本文を表示

config/mongrel_cluster.ymlの書き方、とか November 03, 2006 20:17

Railsプロセス(FastCGI)だけ別サーバにわけたのはいいんだけど、 これじゃ静的ファイルは依然としてlighttpdの動いてるサーバから返されるわけか。 一方でRailsがページキャッシュしたRSSとかアップロードしたファイルとかは Railsのサーバにできるわけだから、なるほどRSSが更新されないわけだわ。

この場合FastCGIのプロセスじゃなくてwebサーバごと一緒に引越ししなくちゃいけなかった。 てことでmongrel cluster。

設定ファイルconfig/mongrel_cluster.ymlの書き方がイミフなのでmongrel_cluster/init.rbをのぞく。

        argv = [ "mongrel_rails" ]
        argv << "start"
        argv << "-d"
        argv << "-e #{@options["environment"]}" if @options["environment"]
        argv << "-p #{port+i}"
        argv << "-a #{@options["address"]}"  if @options["address"]
        argv << "-l #{@options["log_file"]}" if @options["log_file"]
        argv << "-P #{pid[0]}.#{port+i}.#{pid[1]}"
        argv << "-c #{@options["cwd"]}" if @options["cwd"]
        argv << "-t #{@options["timeout"]}" if @options["timeout"]
        argv << "-m #{@options["mime_map"]}" if @options["mime_map"]
        argv << "-r #{@options["docroot"]}" if @options["docroot"]
        argv << "-n #{@options["num_procs"]}" if @options["num_procs"]
        argv << "-B" if @options["debug"]
        argv << "-S #{@options["config_script"]}" if @options["config_script"]
        argv << "--user #{@options["user"]}" if @options["user"]
        argv << "--group #{@options["group"]}" if @options["group"]
        cmd = argv.join " "

        puts cmd if @verbose
        output = `#{cmd}`

mongrel_cluster.ymlはmongrel_rails startに渡すオプションを書くところだったんだなー。 mongrel_rails startのヘルプ見れば対応が分かる。

$ mongrel_rails start -h
Usage: mongrel_rails <command> [options]
    -e, --environment ENV            Rails environment to run as
    -d, --daemonize                  Whether to run in the background or not
    -p, --port PORT                  Which port to bind to
    -a, --address ADDR               Address to bind to
    -l, --log FILE                   Where to write log messages
    -P, --pid FILE                   Where to write the PID
    -n, --num-procs INT              Number of processors active before clients denied
    -t, --timeout TIME               Timeout all requests after 100th seconds time
    -m, --mime PATH                  A YAML file that lists additional MIME types
    -c, --chdir PATH                 Change to dir before starting (will be expanded)
    -r, --root PATH                  Set the document root (default 'public')
    -B, --debug                      Enable debugging mode
    -C, --config PATH                Use a config file
    -S, --script PATH                Load the given file as an extra config script.
    -G, --generate CONFIG            Generate a config file for -C
        --user USER
                                     User to run as
        --group GROUP
                                     Group to run as
        --prefix PATH
                                     URL prefix for Rails app
    -h, --help                       Show this message
        --version                    Show version

こうなった。

---
port: 8000
pid_file: log/mongrel.pid
servers: 3
mime_map: config/mongrel_mime_type.yml
environment: production

サーバは3つもあればこんなブログ十二分にさばけるお!

mongrelがrdfのcontent typeをしっかり返さないので、mongrel_mime_type.ymlに書いた。

.rdf: text/xml; charset=UTF-8

application/rdf+xmlはどうなったんだろう。なんかそれにするとオレのFirefox 1.5は xmlとして見てない感じだよ。

あとはlighttpdでやってたrewriteをどうすっかなんだけど、

Mongrel (as of 0.3.7) by default supports Rails style page caching in the RailsHandler it uses to serve your applications. What this means is that if you do a page cached action (which writes a .html file as well as respond) then Mongrel will just serve up the cached page instead of bug Rails.

mongrelは.htmlを付けるのはやってくれるらしいことが書かれている。

そのほかのrewriteはLuaでpower-magnet.cmlてのをlighttpd用に書くみたいだけど、 とりあえずいいや。今回は必要ない。