egg icon indicating copy to clipboard operation
egg copied to clipboard

Enable plugin dynamically

Open sm2017 opened this issue 4 years ago • 10 comments

How can I enable plugin at runtime?

See https://github.com/eggjs/egg/issues/3262#issuecomment-444483287

I want to have a disabled redis in workers and enable it later at some worker startup

sm2017 avatar Aug 01 '19 07:08 sm2017

Also I have same process.env.EGG_SERVER_ENV for both application and workers , process.env.EGG_SERVER_ENV=prod

sm2017 avatar Aug 01 '19 07:08 sm2017

Reply please

sm2017 avatar Aug 02 '19 06:08 sm2017

No, the plugins can't be disable after application startup

whxaxes avatar Aug 04 '19 15:08 whxaxes

@whxaxes I don't want disable it , I want enable after application startup

sm2017 avatar Aug 05 '19 06:08 sm2017

@sm2017 It also can't be enable after application startup. Why you need to enable plugin later at startup?

whxaxes avatar Aug 05 '19 06:08 whxaxes

I have a egg web application, and need to create some cli application TO SHARE CODES I CREATED IN WE APP , I use egg with commander js for cli applications, commander js parses args and according to first arg , we have different cli application

I need to disable some plugin , in some cli application, but dont want to create multiple env or many config files I

sm2017 avatar Aug 05 '19 13:08 sm2017

Sorry, eggjs doesn't support enable plugin dynamically now, Using multiple config files instead.

whxaxes avatar Aug 08 '19 02:08 whxaxes

you can pass an option plugins to specify which plugin can be enable/disable

popomore avatar Aug 13 '19 07:08 popomore

@popomore how exactly?

sm2017 avatar Aug 13 '19 11:08 sm2017

Using EGG_PLUGINS https://github.com/eggjs/egg-core/blob/master/lib/loader/mixin/plugin.js#L72

Or options.plugins https://github.com/eggjs/egg-core/blob/master/lib/loader/mixin/plugin.js#L81

popomore avatar Oct 23 '19 12:10 popomore