我正在使用this mongodb3 cookbook
來安裝mongodb實例。廚師:mmake確定一項服務正在網絡上偵聽
我想,當服務開始執行腳本:
execute "Add Mongo Users" do
command "mongo #{host}:#{port} /tmp/mongo.setup.users.js"
subscribes :run, 'service[mongod]', :delayed
end
我得到這個錯誤:
==> Expected process to exit with [0], but received '1'
==> ---- Begin output of mongo localhost:30158 /tmp/mongo.setup.users.js ----
==> STDOUT: MongoDB shell version v3.4.2
==> connecting to: localhost:30158
==> 2017-06-05T07:39:48.136+0000 W NETWORK [thread1] Failed to connect to 127.0.0.1:30158, in(checking soc
ket for error after poll), reason: Connection refused
==> 2017-06-05T07:39:48.136+0000 E QUERY [thread1] Error: couldn't connect to server localhost:30158, co
nnection attempt failed :
所以,你可以看到,服務尚未運行時命令執行(我收到網絡錯誤)。
我看了一下cookbook的存儲庫代碼。根據this peace of code,服務開始...
任何想法?
可能是該命令有點太快。觸發服務啓動並不意味着它已準備好接受連接。 – StephenKing
請注意您的主題中的拼寫。 – StephenKing
也許更新'command'參數的值並預先輸入'ss -ntl;'先輸出監聽端口列表(檢查我是否正確)。 – StephenKing