[id: string]: any;
}
let workers: WorkerMap = {};
+let runner: any;
Object.defineProperty(global, 'serviceType', {
value: wrt.getServiceModel(),
writable: false
});
-function isServiceApplication() {
- return global['serviceType'] !== 'UI';
+function isStandalone() {
+ return global['serviceType'] === 'STANDALONE';
}
function createWorker(id: string, startService: string, filename: string) {
export function startService(id: string, filename: string) {
console.log(`startService - ${id}`);
- let startService = `${__dirname}/service_runner.js`;
- createWorker(id, startService, filename);
+ if (isStandalone()) {
+ runner = require('../common/service_runner');
+ runner.start(id, filename);
+ } else {
+ let startService = `${__dirname}/service_runner.js`;
+ createWorker(id, startService, filename);
+ }
}
export function stopService(id: string) {
console.log(`stopService - ${id}`);
- terminateWorker(id, 500);
+ if (isStandalone()) {
+ if (!runner) {
+ console.log('runner instance is null in standalone mode');
+ return;
+ }
+ runner.stop(id);
+ } else {
+ terminateWorker(id, 500);
+ }
}
export function handleBuiltinService(serviceId: string, serviceName: string) {