我正在使用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