I asked this question before
#3262
#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
I create a complex RESTful web service by eggjs , it have many services and plugins
I want to create workers (some js scripts) for my messaging queue (rabbitmq) and I want to reuse services and plugins , so I need to access to ctx object
const runWorker = ()=>{
// some code here
//here I need eggjs service
const configs = {
baseDir : 'mainAppDir'
};
const egg= //Create a single mode eggjs instance
const ctx = egg.createAnonymousContext();
}
7条答案
按热度按时间sr4lhrrt1#
@sm2017 try this:
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.nkoocmlb2#
@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?
xhv8bpkk3#
@atian25 I run your code in a fresh installed simple mode eggjs
2admgd594#
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.
6rqinv9w5#
@atian25 I run your code in a fresh installed simple mode eggjs
What about this error?
a14dhokn6#
@atian25 reply please
83qze16e7#
@atian25 just to remove
inactive
tag