追記 2018/08/01
gcloud components update 来てたので、した。
goapp serve の "There are too many files" Warning は無くなったけど、代わりに hot rebuild もなくなってる?
— エロリツイート先生 (@otiai10) August 1, 2018
% goapp version
go version 1.9.4 (appengine-1.9.74) darwin/amd64
追記
gcloud components update
するとgoogle-cloud-sdk以下のファイルが更新されて魔改造が吹っ飛ぶ。かなしみ。
問題
% goapp serve INFO 2017-06-07 01:58:24,616 devappserver2.py:692] Skipping SDK update check. INFO 2017-06-07 01:58:24,646 api_server.py:272] Starting API server at: http://localhost:52623 INFO 2017-06-07 01:58:24,648 dispatcher.py:205] Starting module "default" running at: http://localhost:8080 INFO 2017-06-07 01:58:24,650 admin_server.py:116] Starting admin server at: http://localhost:8000 /Users/otiai10/.google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/mtime_file_watcher.py:157: UserWarning: There are too many files in your application for changes in all of them to be monitored. You may have to restart the development server to see some changes to your files. 'There are too many files in your application for '
となって、編集検知のオートビルドされなくてちょっと困る。
調査
なんかdevappserver
のコード魔改造するしかなさそう。今んとこ。
解決
appengine/tools/devappserver2/mtime_file_watcher.py
を以下のように編集。まずはわかりやすいように。
diff --git a/watcher_common.py b/watcher_common.py index fe47078..6541de6 100755 --- a/watcher_common.py +++ b/watcher_common.py @@ -47,6 +47,11 @@ def ignore_file(filename, skip_files_re=None): Returns: Boolean value, True if the filename can be ignored. """ + if not filename.startswith(os.getcwd()): + return True + if filename.find('/node_modules/') is not -1: + return True + if skip_files_re and skip_files_re.match(filename): return True filename = os.path.basename(filename)
- カレントディレクトリ以下のファイル以外は監視対象から除外
node_modules
は監視対象から除外
適宜
適宜、たとえば
diff --git a/watcher_common.py b/watcher_common.py index fe47078..ad1f641 100755 --- a/watcher_common.py +++ b/watcher_common.py @@ -47,6 +47,11 @@ def ignore_file(filename, skip_files_re=None): Returns: Boolean value, True if the filename can be ignored. """ + + # Watch ONLY current directory if env "GOAPP_WATCH_CWD" is found + if os.getenv('GOAPP_WATCH_CWD') and not filename.startswith(os.getcwd()): + return True + if skip_files_re and skip_files_re.match(filename): return True filename = os.path.basename(filename) @@ -67,7 +72,11 @@ def _remove_pred(lst, pred): def ignore_dir(dirpath, dirname, skip_files_re): """Report whether a directory should not be watched.""" + + # List of directory names to be ignored; e.g. "node_modules", "vendor" or so + _IGNORED_DIRS = ('node_modules') return (dirname.startswith(_IGNORED_PREFIX) or + (dirname in _IGNORED_DIRS) or skip_files_re and skip_files_re.match(os.path.join(dirpath, dirname)))
のようにしたらオシャレなのではないか。魔改造には変わりないけど。
DRYな備忘録として
はじめてのGoogle App Engine Go言語編 (I・O BOOKS)
- 作者: 茨木隆彰
- 出版社/メーカー: 工学社
- 発売日: 2012/02/01
- メディア: 単行本
- クリック: 2回
- この商品を含むブログ (4件) を見る
Go言語プログラミング入門on Google App Engine
- 作者: 横山隆司
- 出版社/メーカー: 秀和システム
- 発売日: 2011/12/14
- メディア: 単行本
- クリック: 1回
- この商品を含むブログ (6件) を見る
- 作者: Dan Sanderson,玉川竜司
- 出版社/メーカー: オライリージャパン
- 発売日: 2011/01/24
- メディア: 大型本
- 購入: 5人 クリック: 414回
- この商品を含むブログ (27件) を見る