GAE/J EclipseのGoogleプラグインで起動するWebサーバのリスンアドレス、ポートを変更する
EclipseのGoogleプラグインを使ってローカル環境でサーバを起動するとき、通常サーバは127.0.0.1:8080で待ち受け状態になる。しかし、これだと他のPCからアクセスできないので、サーバを起動するときに以下のオプションをつけることで、他のPCからもアクセス出来るようになる。
--address=0.0.0.0
以下はポートまで指定した例。
この場合、以下のようにリスンされる
C:\WINDOWS\system32>netstat -an|find "3001" TCP 0.0.0.0:3001 0.0.0.0:0 LISTENING
なので、このPCがたとえば「192.168.0.50」で動いていたとすれば、他のPCから「http://192.168.0.50:3001/」でアクセスできることになる。(ファイアウォールとかあるならそれは解除してね)
設定するには、Eclipseのメニューの実行ボタン横の小さい三角を押し「Run Configurations」を選択。左ペインの「WebApplication」を選んでアプリケーションを選ぶ。そして、右側の「Arguments」タブを開くと上記の図の画面になるのでそこにパラメータを指定。
ちなみにパラメータには他にも以下のものが指定出来そう。(あ、-a=0.0.0.0でもいいんだね。)
Usage: <dev-appserver> [options] <war directory> Options: --help, -h Show this help message and exit. --server=SERVER The server to use to determine the latest -s SERVER SDK version. --address=ADDRESS The address of the interface on the local machine -a ADDRESS to bind to (or 0.0.0.0 for all interfaces). --port=PORT The port number to bind to on the local machine. -p PORT --sdk_root=root Overrides where the SDK is located. --disable_update_check Disable the check for newer SDK versions.