问题
I'm using sails on a project hosted on Heroku. I have a web process running a sails web server and a worker process using the same Models as the ones used by the web server.
In order to make it possible I have different way to start each process with the same code :
- the app.js standard way
- a worker.js file that starts the same sails app with only the orm and services hook activated.
However I have added some user hooks in a api/hooks folder that I don't want the worker to start. Is there an easy way to disable those hooks? I tried to lift sails with a { "userhookname" : false } passed in config but it does not seem to work.
Thank you
回答1:
Sails.js doesn't currently support disabling individual user hooks in the same way as the core hooks, although it certainly makes sense to implement that feature. In the meantime, the simplest thing to do is to just implement a toggle within the hook itself. In the defaults
, provide an active
key that defaults to true
, and then in initialize
, check that active
is true
before continuing. See sails-hook-autoreload for an example.
来源:https://stackoverflow.com/questions/30580472/disable-user-hook-in-sails