I have made a nodejs application using sails.js. It's working perfectly in my localhost. The problem appears in production when I try to publish it in the server(modulus). You can take a look the error below.
Error: The hook `pubsub` is taking too long to load.
Make sure it is triggering its `initialize()` callback, or else set `sails.config.pubsub._hookTimeout to a higher value (currently 20000)
at tooLong [as _onTimeout] (/mnt/data/1/ApiDevConf-master/node_modules/sails/lib/app/private/loadHooks.js:92:21)
at Timer.listOnTimeout (timers.js:110:15) { [Error: The hook `pubsub` is taking too long to load.
Make sure it is triggering its `initialize()` callback, or else set `sails.config.pubsub._hookTimeout to a higher value (currently 20000)] code: 'E_HOOK_TIMEOUT' }
I have tried to figure out how to solve the problem but nothing works. I was trying somethink like this here.
Also I have properly set the NODE_ENV = production
Thanks for your time.
It sounds like this could be one of two issues.
1.) You need to set your migrate setting in config/model.js
to something besides alter
. You should have migrate: 'safe'
on in production mode. This should happen automatically if the NODE_ENV variable is set to production
.
The reason it times out is every time you start the server Sails will try and migrate your existing data to the current schema. Obviously don't want this in production.
2.) You have a lot of files to load and Modulus is slow to read them from it's virtual disk. This is a bigger issue because it will take a very long time for your server to start each time you need to restart it. You can bump the global timeout limit and that should give you more time. To do that add the following to your config/env/production.js
file:
module.exports = {
hookTimeout: 40000
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With