How To Cancel Sails.js Lift With A Hook
Solution 1:
First off, if the initialization tasks are specific to your application, you may be able to just use the bootstrap instead of a hook. Calling the bootstrap callback with an error as the argument will cause Sails to bail out.
If you do definitely need to use a hook, you can force Sails to exit in much the same way--calling the callback from within the initialize
method of the hook with any non-null argument will signal a failure, and cause Sails to exit. This is the case with Node apps in general: any time you are expected to call a callback, passing a non-null value as the first argument will signal an error.
So, if your hook's initialize
kicks off the tasks you need to run, and doesn't call cb()
until they are all completed, and calls cb(<some error>)
at any point where the tasks fail, then you'll have a situation where Sails won't load until the hook is finished, and bails out if the hook fails to complete its tasks.
Post a Comment for "How To Cancel Sails.js Lift With A Hook"