本文介绍了钩子 orm 加载时间过长的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用两个带有风帆的数据库适配器.

i am using two database adapters with sails.

一个用于 mondoDB,第二个用于 mysql.每当我运行命令sails lift".一旦它给出错误

one for mondoDB and second for mysql.whenever i run command "sails lift".once it gives an error

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

当我重新运行sails而不做任何更改时,它不会出错.我如何每次都避免这个错误.这是我第一次使用sailsjs,所以任何帮助都会受到赞赏....

when i rerun sails without changes it gives no error then.how can i avoid this error everytime.this is my 1st experience with sailsjs so any help will be apreciated....

推荐答案

我昨晚遇到了这个问题,因为我的笔记本电脑和数据库服务器之间的互联网连接速度很慢.我的解决方案是在 config 目录中创建一个名为 orm.js 的新文件(名称并不重要).

I ran into this problem last night because of a slow internet connection between my laptop and the DB server. My solution was to create a new file in the config directory called orm.js (name doesn't really matter).

然后添加以下代码:

// config/orm.js
module.exports.orm = {
  _hookTimeout: 60000 // I used 60 seconds as my new timeout
};

我还发现我必须更改我的发布订阅超时,但这对您来说可能没有必要.

I also found I had to change my pubsub timeout but that may not be necessary for you.

// config/pubsub.js
module.exports.pubsub = {
  _hookTimeout: 60000 // I used 60 seconds as my new timeout
};

注意:另一个答案建议更改node_modules 文件夹中的sails 文件.这几乎总是一个坏主意,因为任何 npm update 都可以恢复您的更改.

Note: The other answer recommends changing the sails files inside the node_modules folder. This is almost always a bad idea because any npm update could revert your changes.

这篇关于钩子 orm 加载时间过长的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-06 15:50