[英]Exec command time out Error when running nodejs app using puppet
我正在克隆存儲庫並使用puppet運行我的nodejs應用程序。 請找到以下代碼:
package { 'git':
ensure => 'latest',
}
vcsrepo { "/nodejs-helloworld":
ensure => latest,
provider => git,
require => [ Package["git"] ],
source => "git@gitlab.abc.dev.net:hello-world/nodejs-helloworld.git",
revision => 'master',
before => Exec['/usr/local/bin/npm install;/usr/local/bin/npm start'],
}
exec { '/usr/local/bin/npm install;/usr/local/bin/npm start':
cwd => '/nodejs-helloworld',
subscribe => Vcsrepo['/nodejs-helloworld'],
refreshonly => true,
}
我的存儲庫已克隆,我的應用程序運行正常,並且npm test
也有效。 一切正常。 但是,我收到一個exec命令超時錯誤。
錯誤日志:
[root@ip-*******/]# puppet agent -t
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Loading facts
Info: Caching catalog for ip-**************
Info: Applying configuration version '1474433486'
Notice: /Stage[main]/Main/Exec[install-node-version-manager-global]/returns: executed successfully
Notice: /Stage[main]/Main/Exec[install-node-version-manager-latest]/returns: executed successfully
Notice: /Stage[main]/Main/Vcsrepo[/nodejs-helloworld]/ensure: Creating repository from latest
Notice: /Stage[main]/Main/Vcsrepo[/nodejs-helloworld]/ensure: created
Info: /Stage[main]/Main/Vcsrepo[/nodejs-helloworld]: Scheduling refresh of Exec[/usr/local/bin/npm install;/usr/local/bin/npm start]
Error: /Stage[main]/Main/Exec[/usr/local/bin/npm install;/usr/local/bin/npm start]: Failed to call refresh: Command exceeded timeout
Error: /Stage[main]/Main/Exec[/usr/local/bin/npm install;/usr/local/bin/npm start]: Command exceeded timeout
Notice: Finished catalog run in 302.86 seconds
如您在這里看到的,即使我收到exec命令超時錯誤,我的應用程序npm test
運行並且npm test
有效。
[root@ip-********* nodejs-helloworld]# netstat -anp 2> /dev/null | grep :3000
tcp6 0 0 :::3000 :::* LISTEN 17630/node
[root@ip-********* nodejs-helloworld]# npm test
> nodejs-helloworld@1.0.0 test /nodejs-helloworld
> mocha
Test HelloWorld
✓ Should have the root route (46ms)
✓ Should have a hello world response
2 passing (66ms)
誰能告訴我如何避免exec命令超時錯誤?
如果我沒記錯,那似乎是問題所在,當您運行npm start
,它會運行您的應用程序,但它不會退出,並且您不希望這樣做,因為您想保持應用程序的運行,但是請執行puppet希望它在某個時候退出。
相反,您應該做的是使exec
資源在后台啟動您的應用程序。 您可以看一下這個問題 ,其中的答案描述了可以輕松實現這一目標的各種工具。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.