无法将Sails.js应用程序投入生产

我试图用Sails.js将我的应用程序投入生产,但无法通过咕噜声的任务。 这是我收到的错误:

error: Error: The hook `grunt` is taking too long to load. Make sure it is triggering its `initialize()` callback, or else set `sails.config.grunt._hookTimeout to a higher value (currently 20000) at tooLong [as _onTimeout] (/usr/local/lib/node_modules/sails/lib/app/private/loadHooks.js:92:21) at Timer.listOnTimeout (timers.js:110:15) 

我大大增加了sails.config.grunt._hookTimeout ,但仍然没有完成。 在生产或开发输出中运行sails debug

 Grunt :: Error: listen EADDRINUSE at exports._errnoException (util.js:746:11) at Agent.Server._listen2 (net.js:1156:14) at listen (net.js:1182:10) at Agent.Server.listen (net.js:1267:5) at Object.start (_debugger_agent.js:20:9) at startup (node.js:86:9) at node.js:814:3 

我感到奇怪的是,在开发模式下一切正常,但在生产中却不是这样。 包括的文件是相当大的,如angular度,时刻和其他模块。 这就是jsFilesToInject外观:

 var jsFilesToInject = [ // Load sails.io before everything else 'js/dependencies/sails.io.js', 'js/dependencies/angular.min.js', 'js/dependencies/moment.min.js', 'js/dependencies/angular-ui-router.min.js', 'js/dependencies/angular-sails.min.js', 'js/dependencies/angular-moment.min.js', 'js/dependencies/angular-animate.min.js', 'js/dependencies/angular-aria.min.js', 'js/dependencies/angular-material.min.js', // All of the rest of your client-side js files // will be injected here in no particular order. 'js/**/*.js' ]; 

我不知道还有什么会导致这个,有什么build议吗? 我正在使用Sails版本0.11.0

我只是有这个相同的问题,只是超时不够大,我不得不把这个在我的config / local.js文件:

 module.exports = { hookTimeout: 120000 }; 

我只是在github上发布了相同的问题,然后签出了源代码。 所以我通过咕噜咕噜读了解发生了什么。 事实certificate,在default模式下,grunt钩子会在grunt启动后立即触发callback,但是对于prod模式,只有在grunt完成所有任务后才会触发。

源代码中有以下评论:

cb – 可选,在Grunt任务开始(非生产)或完成(生产)时触发

所以如果在prod有什么东西在看(比如在browserify中使用watch ),那么grunt任务将永远不会退出,所以grunt钩子总是会超时。 但是,即使没有什么东西在看,开始咕噜的任务需要更长的时间才能完成所有的任务,这就解释了为什么我们没有看到生产模式下的问题。 由于修改原始的grunt钩子并不是最好的办法(它存在于node_modules ),所以最好的办法是增加(可能显着的) _hookTimeout选项并确保grunt任务退出(为此可以用grunt prod单独运行) 。