Open sm2017 opened 4 years ago
@sm2017 try this:
const { Application, Agent } = require('egg');
const agent = new Agent(options);
await agent.ready();
const app = new Application(options);
await app.ready();
app.agent = agent;
agent.application = app;
that is the mini init work at egg-cluster or egg-mock
but you need to start HTTP server yourself and handler gracefull exit.
we will provide a createInstance
to do this at egg 3.0 later this year.
@atian25 I must enable all plugins too
How you pass single mode
in options?
Also I don't need Agent must I create an instance of agent?
@atian25 I run your code in a fresh installed simple mode eggjs
2020-05-17 10:36:22,279 WARN 3912 [egg:core:ready_timeout] 10 seconds later node_modules\egg-watcher\lib\init.js:15:14 was still unable to finish.
const { Application } = require('egg');
const app = new Application(options);
await app.ready();
but some plugin required Agent, so maybe you could disable the plugin.
since this way is more like a hacky, so I can't promise everything will work fine.
@atian25 I run your code in a fresh installed simple mode eggjs
2020-05-17 10:36:22,279 WARN 3912 [egg:core:ready_timeout] 10 seconds later node_modules\egg-watcher\lib\init.js:15:14 was still unable to finish.
What about this error?
@atian25 reply please
@atian25 just to remove inactive
tag
I asked this question before https://github.com/eggjs/egg/issues/3262 https://github.com/eggjs/egg/issues/4183
It is too complicated for me!!
How can I run eggjs in single mode and create an anonymous context? I want to Run eggjs as library