1 import { Worker, isMainThread } from 'worker_threads';
2 import { wrt } from '../browser/wrt';
7 let workers: WorkerMap = {};
8 let serviceType: string = wrt.getServiceModel();;
11 function isStandalone() {
12 return serviceType === 'STANDALONE';
15 export function startService(id: string, filename: string) {
16 console.log(`startService - ${id}`);
18 runner = require('../common/service_runner');
19 runner.start(id, filename);
22 let startService = __dirname + '/service_runner.js';
23 workers[id] = new Worker(startService, { workerData: { id: id, filename: filename } });
28 export function stopService(id: string) {
29 console.log(`stopService - ${id}`);
32 console.log('runner instance is null in standalone mode');
36 setTimeout(() => process.exit(), 500);
38 workers[id].postMessage('stopService');
40 workers[id].terminate();