Edgemicro reloads its config every 10 minute (Ok) but also re-init plugins (NOk!)

Hello,

as Expected by the default config_change_poll_interval=600 value, EMG check for online configuration change every 10 minutes. In case something changes in the config, then EMG reloads. This is expected.

What is NOT expected (at least from me) is the fact that -- part of the reload -- plugins are also re-loaded and re-initialized (their .init() entry point is called). This is wreaking havoc in my custom plugins, because their entry point (which is expected to be called once in the process lifetime) is now called multiple times.

How can I avoid plugins to be re-initialized, or how can I (from the custom plugin code) detect that the initialisation code is is not called for the first time? A module.exports.initCount is reset at 0 at each reload sequence.

2 5 371
5 REPLIES 5

Former Community Member
Not applicable

Hello @Francois-Xavier KOWALSKI, the behaviour you are observing is by design. Edgemicro "reload" has the same effect as a restart. This is to allow operators to add/remove plugins, make any other configuration changes without requiring a full restart.

Let me discuss this internally to see if there is something we can do to accommodate this.

Thanks for this preliminary answer @Srinandan Sridhar,

So init() needs to be idempotent & is called multiple times. That should probably be made more clear in the documentation http://docs.apigee.com/microgateway/latest/develop-custom-plugins#abouttheplugininitfunction.

I could deal with it provided my plugin code had access so _some_ indicator that init() is being called multiple times.

Any news @Srinandan Sridhar from your internal conversation on this auto-re-init issue?

Former Community Member
Not applicable

Yes, we cannot support this at the moment.

Argh. Not even a load counter I could have a look at?