現場ではlocalhostにデプロイする時にWAS(WebSphere Application Server)の設定とかするのに、 家でrailsとかtornadoとかデプロイする時にサーバーとアプリのつなぎ込み?した覚えがない!なんで!
仮説
調べてみたら、tornadoはwebサーバーとしての機能も持っていた。 railsもサーバーとしての機能を持っているのではないか。 ただし、サーバーを別途立てて運用することもできるのではないか(railsとunicornの単語をセットで見かけたことがあるから)
やってみた
railsアプリケーションを動かしてみるのが一番。 今回は他にもFlask(PythonのWAF)とPlay(Java/ScalaのWAF)も動かしてみた。
Rails
$ hello_app hiroaki$ rbenv exec rails s => Booting Puma => Rails 5.0.5 application starting in development on http://localhost:3000 => Run `rails server -h` for more startup options Puma starting in single mode... * Version 3.9.1 (ruby 2.3.4-p301), codename: Private Caller * Min threads: 5, max threads: 5 * Environment: development * Listening on tcp://0.0.0.0:3000 Use Ctrl-C to stop
調べたところ、デフォルトでPumaというwebサーバーが指定されているらしい。
Flask
$ python project.py * Running on http://0.0.0.0:5000/ * Restarting with reloader
シンプルだなあ… Flaskは開発用のWEBサーバーを内蔵している、という記述を見つけたから、 Flask内部のWerkzeug(ウェルクツォイク、WAFのためのユーティリティ)が、同梱されているwebサーバと通信しているというイメージであってるかな?
Play
$ sbt run [warn] Executing in batch mode. [warn] For better performance, hit [ENTER] to switch to interactive mode, or [warn] consider launching sbt without any commands, or explicitly passing 'shell' [info] Loading project definition from /Users/hiroaki/Dev/lrn/play/play-java-starter-example/project [info] Set current project to play-java-starter-example (in build file:/Users/***/play-java-starter-example/) --- (Running the application, auto-reloading is enabled) --- [info] p.c.s.AkkaHttpServer - Listening for HTTP on /0:0:0:0:0:0:0:0:9000 (Server started, use Enter to stop and go back to the console...)
Akka HTTPというプロジェクトで作られたWEBサーバーが動いているらしいということはわかった。
結論
有名なWAFには、開発用のサーバーが一緒に入ってる、と考えて良いのではなかろうか。 いざ運用、という段になったら、専用のサーバーを立ててアプリを叩くように設定するのだと思われる。