WindowsでRuby on Railsサーバ構築 (Mongrel編)
[参考記事] Mongrelのインストール
[参考記事] サーバ構築 (WEBrick編)
[参考記事] Railsをクリックだけで起動する方法
Windowsでサーバを構築する場合、立ち上げておくアプリケーションをサービスとして登録します。
Mongrelではサービスとして実行するためのgemパッケージ『 mongrel_service 』が用意されています。
mongrel_serviceでは、サービスの登録・解除以外にMongrelの起動・停止・再起動も可能です。
mongrel_serviceのインストール
gemをインストールするには、コマンドプロンプトで下記のコマンドを実行します。
gem install mongrel_service
C:\>gem install mongrel_service
Successfully installed win32-service-0.5.2-x86-mswin32
Successfully installed mongrel_service-0.3.4-x86-mswin32
2 gems installed
Installing ri documentation for win32-service-0.5.2-x86-mswin32...
Installing ri documentation for mongrel_service-0.3.4-x86-mswin32...
Installing RDoc documentation for win32-service-0.5.2-x86-mswin32...
Installing RDoc documentation for mongrel_service-0.3.4-x86-mswin32...
サービスの登録
mongrel_rails service::install -N "【サービス名】" -c 【railsのパス】 -p 【ポート番号】 -e 【作動環境】
C:\>mongrel_rails service::install -N "rails_app" -c C:\workspace\rails -p 80 -e production
** Copying native mongrel_service executable...
Mongrel service 'rails_app' installed as 'rails_app'.
このコマンドは、あくまでもサービスの登録のためのものなので、これだけでは登録されたサービスは起動しません。
登録されたサービスは、
コントロールパネル
↓
パフォーマンスとメンテナンス
↓
管理ツール
↓
サービス
で、確認できます。
登録されたサービスを開いて、『開始』ボタンをクリックするとMongrelが起動します。
Windows起動時に自動的に起動させるには、『スタートアップの種類』を『自動』に変更します。
サービスの解除(削除)
mongrel_rails service::remove -N "【サービス名】"
C:\>mongrel_rails service::remove -N "rails_app"
rails_app service removed.
mongrel_serviceのヘルプ一覧
C:\>mongrel_rails Usage: mongrel_rails <command> [options] Available commands are: - restart - start - stop - service::install - service::remove Each command takes -h as an option to get help.
C:\>mongrel_rails restart -h
Usage: mongrel_rails <command> [options]
-c, --chdir PATH Change to dir before starting (will be expanded)
-s, --soft Do a soft restart rather than a process exit restart
-P, --pid FILE Where the PID file is located
-h, --help Show this message
--version Show version
C:\>mongrel_rails start -h
Usage: mongrel_rails <command> [options]
-e, --environment ENV Rails environment to run as
-d, --daemonize Run daemonized in the background
-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-processors INT Number of processors active before clientsdenied
-o, --timeout TIME Time to wait (in seconds) before killing astalled thread
-t, --throttle TIME Time to pause (in hundredths of a second) between accepting clients
-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 PATH Generate a config file for use with -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
C:\>mongrel_rails stop -h
Usage: mongrel_rails <command> [options]
-c, --chdir PATH Change to dir before starting (will be expanded).
-f, --force Force the shutdown (kill -9).
-w, --wait SECONDS Wait SECONDS before forcing shutdown
-P, --pid FILE Where the PID file is located.
-h, --help Show this message
--version Show version
C:\>mongrel_rails service::install -h
Usage: mongrel_rails <command> [options]
-N, --name SVC_NAME Required name for the service to be registered/installed.
-D, --display SVC_DISPLAY Adjust the display name of the service.
-e, --environment ENV Rails environment to run as
-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 clientsdenied
-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.
--prefix PATH
URL prefix for Rails app
-h, --help Show this message
--version Show version
C:\>mongrel_rails service::remove -h
Usage: mongrel_rails <command> [options]
-N, --name SVC_NAME Required name for the service to be registered/installed.
-h, --help Show this message
--version Show version
関連記事
- NetBeansでRuby on Railsを開発する
- WindowsでRuby on Railsサーバ構築 (WEBrick編)
- Ruby on Railsをクリックだけで起動する方法
- URLとコントローラ・アクション、ビューの関係
- db/seed.rbで初期データ投入 (rake db:seed)
- rakeのタスク一覧
- rake --helpとrake -Tの実行結果
- Ruby on Railsのマイグレーションの型とMySQLの型の対応表
- Ruby on Railsをバージョンを指定してインストールする方法
- WEBrick互換の軽量WebサーバMongrel
- EclipseでRuby on Rails開発環境を作る RadRails
- Ruby on Railsのインストールと起動
- ディレクトリ構成
- Ruby on Railsとは
スポンサーリンク





