sgress454 / sails-hook-autoreload

Sails JS hook to autoreload controllers and models when changed.
231 stars 44 forks source link

Reload policies #65

Open Fr33maan opened 8 years ago

Fr33maan commented 8 years ago

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

CiscoKidxx commented 8 years ago

Also curious about this

CiscoKidxx commented 8 years ago

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

Fr33maan commented 7 years ago

Did you gave it a try ?

Fr33maan commented 7 years ago

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

Fr33maan commented 7 years ago

@sgress454 any clue on how to reload policies ?

tylercollier commented 7 years ago

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. :-(

jhereu commented 7 years ago

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.

sgress454 commented 7 years ago

@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.

Fr33maan commented 7 years ago

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 ?

sgress454 commented 7 years ago

@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.

Fr33maan commented 7 years ago

@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 commented 7 years ago

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