簡體   English   中英

掛在npm上的廚師客戶端安裝在node-gyp rebuild

[英]Chef client hanging on npm install at node-gyp rebuild

從主廚配方運行npm install遇到問題。 當我從命令行運行它時,它在一分鍾內完成,只有一些與package.json沒有存儲庫字段相關的警告(應該是無害的)。 但是當我從chef運行它時,它會掛起最后一行輸出回命令行,如下所示:

* execute[npm-install-app] action run

配方中的這個資源塊是:

execute "npm-install-app" do
  cwd "#{home}/#{prefix}#{app}"
  command "npm --registry #{priv['url']}:#{priv['port']}#{priv['path']} install --cache #{home}/.npm --tmp #{home}/tmp > npm-run.log 2>&1"
  user node['nodejs']['user']
  action :run
end

#{home}擴展到/home/nodejs ,用戶是nodejs

如您所見,我使用> npm-run.log 2>&1將輸出重定向到文件到文件。 輸出文件獲取寫入它的npm install命令的輸出(與命令行不同),最后一件事是:

-- a bunch of 200's and 304s, like this --
npm http 304 http://my.private.npm.amazonaws.com/registry/_design/app/_rewrite/esprima

kerberos@0.0.3 install /home/nodejs/my-app/node_modules/mongoose-q/node_modules/mongoose/node_modules/mongodb/node_modules/kerberos
(node-gyp rebuild 2> builderror.log) || (exit 0)

kerberos是我們依賴的一個模塊的依賴,但我們自己並沒有使用kerberos。 我從其他來源收集到npm正在運行node-gyp來編譯在npm服務器上打包的不可用的應用程序版本。

它將在該狀態下保持2小時,直到大廚shellout注冊超時並顯示致命錯誤。 ps -e將顯示當chef-client仍在運行時npm仍在運行,並且中斷chef-client將導致npm從進程列表中消失,這表明npm仍然認為它仍然在做有意義的工作,至少。 (另一方面,當我遇到連接問題時,我傾向於問這個問題 。這個npm install很可能是另一個問題的根本問題,但我認為他們需要單獨考慮。)

編輯:使用-l debug運行chef-client會向/var/log/chef/client.log文件添加少量信息,這基本上確認npm install命令是掛起之前要執行的最后一個資源:

[2014-01-09T22:49:28+00:00] INFO: Processing execute[npm-install-app] action run (my-app::default line 111)
[2014-01-09T22:49:28+00:00] DEBUG: Platform ubuntu version 12.04 found

我是否正確地認為|| (退出0)拋出主廚ShellOut提供商檢測成功退出? 我能做些什么嗎?

編輯2: Chef剛從帶有-l debug集的運行-l debug ,並且仍然只獲得有關超時的日志信息。

[2014-01-10T00:26:56+00:00] ERROR: execute[npm-install-app] (my-app::default line 111) had an error: Mixlib::ShellOut::CommandTimeout: command timed out:
---- Begin output of npm --registry http:my.private.npm.amazonaws.com:5984/registry/_design/app/_rewrite install --cache /home/nodejs/.npm --tmp /home/nodejs/tmp > npm-run.log 2>&1 ----
STDOUT:
STDERR:
---- End output of npm --registry http://ec2-54-221-190-191.compute-1.amazonaws.com:5984/registry/_design/app/_rewrite install --cache /home/nodejs/.npm --tmp /home/nodejs/tmp > npm-run.log 2>&1 ----

但! 另一個節點在約5分鍾后成功完成,並在npm-run.log文件中包含此內容:

> kerberos@0.0.3 install /home/nodejs/spicoli-authorization/node_modules/mongoose-q/node_modules/mongoose/node_modules/mongodb/node_modules/kerberos
> (node-gyp rebuild 2> builderror.log) || (exit 0)

make: Entering directory `/home/nodejs/spicoli-authorization/node_modules/mongoose-q/node_modules/mongoose/node_modules/mongodb/node_modules/kerberos/build'
  SOLINK_MODULE(target) Release/obj.target/kerberos.node
  SOLINK_MODULE(target) Release/obj.target/kerberos.node: Finished
  COPY Release/kerberos.node
make: Leaving directory `/home/nodejs/spicoli-authorization/node_modules/mongoose-q/node_modules/mongoose/node_modules/mongodb/node_modules/kerberos/build'

我想不出為什么會出現如此巨大的性能差異,兩台服務器都運行在亞馬遜的小型ec2實例上。 也許在工作和損壞的服務器上的主目錄之間存在權限差異......我將調查該角度。

好吧,我終於脫掉了我的白痴帽子,在正確的地方尋找原木。 該命令甚至說2> builderror.log ,所以你認為只需find一個具有該名稱的文件的提示即可,但它仍然沒有發生在我身上。 這非常令人沮喪,因為node-gyp命令顯然內置於kerberos源代碼中,它默默地隱藏來自任何調用進程的錯誤(如Chef或任何其他可能需要自動進行npm安裝的構建工具)。

這就是它所說的(一遍又一遍地約為350 MB,因此有趣的小掛!我的廚師食譜是刪除每次運行時使用的目錄,或者這可能更難以診斷):

gyp WARN EACCES attempting to reinstall using temporary dev dir "/root/tmp/.node-gyp"
gyp WARN EACCES user "root" does not have permission to access the dev dir "/root/tmp/.node-gyp/0.10.22"

奇怪的是node-gyp正在處理這個位置周圍的文件: /home/nodejs/my-app/node_modules/mongoose-q/node_modules/mongoose/node_modules/mongodb/node_modules/kerberos/ ,我的npm install命令是作為nodejs用戶運行,但它仍然嘗試以root用戶身份寫入/root 對此必須有些不妥,因為root darn具有該目錄的權限。

ubuntu@amazonaws:~$ sudo ls -la /
-- snip --
drwx------  4 root root  4096 Jan  7 22:50 root

ubuntu@amazonaws:~$ sudo ls -la /root
total 24
drwx------  4 root root 4096 Jan  7 22:50 .
drwxr-xr-x 23 root root 4096 Jan  7 22:46 ..
-rw-r--r--  1 root root 3106 Apr 19  2012 .bashrc
drwx------  2 root root 4096 Jan  7 22:50 .cache
-rw-r--r--  1 root root  140 Apr 19  2012 .profile
drwx------  2 root root 4096 Jan  7 22:46 .ssh

起初,我認為我只需要修復/home/nodejs目錄的權限,但我認為這將需要跟進node-gyp開發人員。

至少這解釋了為什么如果我將npm-install命令作為不同的用戶(具有sudo權限)運行,它可以工作。

更新:我最終解決了這個問題,讓npm install以root用戶身份運行,然后chownchmod '安裝的文件。 我用於此的Chef資源塊看起來像這樣:

  # Recursively chown and chmod all files just created
  execute "fixup #{home}/#{prefix}#{app} owner" do
    command "find ./ -exec sudo chown #{node[:nodejs][:user]}:#{node[:nodejs][:user]} {} +"
    cwd "#{home}/#{prefix}#{app}"
  end

  execute "fixup #{home}/#{prefix}#{app} file permissions" do
    command "find ./ -type f -exec sudo chmod 644 {} +"
    cwd "#{home}/#{prefix}#{app}"
  end

  execute "fixup #{home}/#{prefix}#{app} directory permissions" do
    command "find ./ -type d -exec sudo chmod 755 {} +"
    cwd "#{home}/#{prefix}#{app}"
  end

這並沒有解決node-gyp在權限部門中的缺點,如果我在這方面得到直接回復,我將繼續追求並發布另一個答案。

這個問題在我的OSX上掛了大約10分鍾(感覺就像),但它設法完成了。 我使用'sudo npm install'從WebStorm IDE內部啟動的終端安裝mongoose。 (沒有sudo就試過了。)

-
> kerberos@0.0.3 install .../Documents/.../node_modules/mongoose/node_modules/mongodb/node_modules/kerberos
> (node-gyp rebuild 2> builderror.log) || (exit 0)

\
> bson@0.2.12 install .../Documents/.../node_modules/mongoose/node_modules/mongodb/node_modules/bson
> (node-gyp rebuild 2> builderror.log) || (exit 0)

<<<< HERE IS THE STRANGE HANGING >>>>


  CXX(target) Release/obj.target/bson/ext/bson.o
  SOLINK_MODULE(target) Release/bson.node
  SOLINK_MODULE(target) Release/bson.node: Finished
mongoose@3.8.17 node_modules/mongoose
├── regexp-clone@0.0.1
├── hooks@0.2.1
├── mpath@0.1.1
├── mpromise@0.4.3
├── ms@0.1.0
├── muri@0.3.1
├── sliced@0.0.5
├── mquery@0.8.0 (debug@0.7.4)
└── mongodb@1.4.9 (readable-stream@1.0.32, kerberos@0.0.3, bson@0.2.12)

$ ls -al

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM