MCPcopy
hub / github.com/thinkjs/thinkjs / _getWorkerInstance

Method _getWorkerInstance

lib/application.js:138–160  ·  view source on GitHub ↗
(argv)

Source from the content-addressed store, hash-verified

136 });
137 }
138 _getWorkerInstance(argv) {
139 const port = argv.port || think.config('port');
140 const instance = new thinkCluster.Worker({
141 port,
142 host: think.config('host'),
143 sticky: think.config('stickyCluster'),
144 createServer() {
145 const createServerFn = think.config('createServer');
146 const callback = think.app.callback();
147 if (createServerFn) {
148 assert(helper.isFunction(createServerFn), 'config.createServer must be a function');
149 }
150 const server = createServerFn ? createServerFn(callback) : http.createServer(callback);
151 think.app.server = server;
152 return server;
153 },
154 logger: think.logger.error.bind(think.logger),
155 processKillTimeout: think.config('processKillTimeout'),
156 onUncaughtException: think.config('onUncaughtException'),
157 onUnhandledRejection: think.config('onUnhandledRejection')
158 });
159 return instance;
160 }
161 /**
162 * run in worker
163 * @param {Object} argv

Callers 1

runInWorkerMethod · 0.95

Calls 1

configMethod · 0.80

Tested by

no test coverage detected