* run
()
| 227 | * run |
| 228 | */ |
| 229 | run() { |
| 230 | if (pm2.isClusterMode) { |
| 231 | throw new Error('can not use pm2 cluster mode, please change exec_mode to fork'); |
| 232 | } |
| 233 | // start file watcher |
| 234 | if (cluster.isMaster) this.startWatcher(); |
| 235 | |
| 236 | const instance = new ThinkLoader(this.options); |
| 237 | const argv = this.parseArgv(); |
| 238 | try { |
| 239 | if (this._isRunInTest()) { |
| 240 | instance.loadAll('worker', true); |
| 241 | } else if (argv.path) { |
| 242 | instance.loadAll('worker', true); |
| 243 | return this.runInCli(argv); |
| 244 | } else if (cluster.isMaster) { |
| 245 | instance.loadAll('master'); |
| 246 | return this.runInMaster(argv); |
| 247 | } else { |
| 248 | instance.loadAll('worker'); |
| 249 | return this.runInWorker(argv); |
| 250 | } |
| 251 | } catch (e) { |
| 252 | console.error(e.stack); |
| 253 | } |
| 254 | } |
| 255 | }; |
| 256 | |
| 257 | /** |
no test coverage detected