sails-hook-autoreload icon indicating copy to clipboard operation
sails-hook-autoreload copied to clipboard

Reload policies

Open Fr33maan opened this issue 9 years ago • 12 comments

Hello,

During developement if you change policies, they arn't reloaded by the hook, do you think it would be possible to reload them ?

Thanks for your work

Fr33maan avatar Sep 05 '16 14:09 Fr33maan

Also curious about this

CiscoKidxx avatar Oct 14 '16 08:10 CiscoKidxx

It can't be as simple as sails.emit("hook:policies:reload"); in the index.js file can it?

CiscoKidxx avatar Oct 14 '16 09:10 CiscoKidxx

Did you gave it a try ?

Fr33maan avatar Dec 14 '16 21:12 Fr33maan

Reload responses would also be nice as I'm currently changing default responses to make easy server side rendering.

Fr33maan avatar Dec 14 '16 21:12 Fr33maan

@sgress454 any clue on how to reload policies ?

Fr33maan avatar Jan 26 '17 17:01 Fr33maan

I couldn't figure out how to reload the policies. I tried sails.emit("hook:policies:reload");, no go.

I even modified the source code from sails-hook-autoload, adding things like this in the sails.hooks.controllers.loadAndRegisterControllers() section:

// Reload policies
if (sails.hooks.policies) {
  sails.hooks.policies.initialize(function() {
    sails.hooks.policies.loadMiddleware(function() {
      sails.hooks.policies.bindPolicies();
    })
  });
}

No dice. :-(

tylercollier avatar Jun 13 '17 05:06 tylercollier

I just started using this hook and had the very same problem: "how can I reload config files other than policies.js?".

The thing is that whatever you put on config/autoreload.js inside a module.exports.autoreload key (as documentation says) does not make the trick. It turns out that, by default, the export has to be named module.exports['sails-hook-autoreload'] instead, as this.configKey at the hook defaults to sails-hook-autoreload.

Solution: Either you change the configKey value inside the hook or you change your module.exports key. I'll submit a PR soon with that.

jhereu avatar Aug 03 '17 06:08 jhereu

@l1br3 @JHereu @tylercollier Thanks for using Sails! We've decided to end official support for this hook, as detailed in the end-of-life notice. If you're interested in taking over, please contact @sgress454.

sgress454 avatar Aug 31 '17 14:08 sgress454

So sad :( there is still so many downloads a day Thanks for this work on the hook, it's still very important for me. Which replacement solution do you use ?

Fr33maan avatar Aug 31 '17 14:08 Fr33maan

@l1br3 I appreciate that, and if it works for you, by all means continue. As fas as replacements, the advent of SDD drives has personally made the ol' CTRL-C + sails lift combo a lot less painful for me, but this article has some good steps for getting forever to do live reload for you. Combining that with a local Redis store for persistent sessions and sockets should be a pretty good alternative to sails-hook-reload.

sgress454 avatar Aug 31 '17 14:08 sgress454

@sgress454 Does SDD stands for spite development driven ? Could I be add to the contributor list ? I don't want this hook to die since I'm able to use it as I want to.

Fr33maan avatar Sep 06 '17 12:09 Fr33maan

@sgress454 thanks for the quick add to contributor list. I will try to keep this one alive

Fr33maan avatar Sep 06 '17 14:09 Fr33maan