From: DongHyun Song Date: Fri, 6 Nov 2020 00:39:03 +0000 (+0900) Subject: [Service][VD] Apply main thread with standalone model X-Git-Tag: accepted/tizen/6.0/unified/20201110.010759^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F90%2F246990%2F6;p=platform%2Fframework%2Fweb%2Fwrtjs.git [Service][VD] Apply main thread with standalone model With standalone model of service application, this patch will apply main thread service_runner to solve crash problems of node worker. Change-Id: I5fb69368a4bae36ac11d465200b2cd0a42e6c3a1 Signed-off-by: DongHyun Song --- diff --git a/wrt_app/common/service_manager.ts b/wrt_app/common/service_manager.ts index 757688b..14f0a87 100644 --- a/wrt_app/common/service_manager.ts +++ b/wrt_app/common/service_manager.ts @@ -5,14 +5,15 @@ interface WorkerMap { [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) { @@ -48,13 +49,26 @@ function terminateWorker(id: string, delay: number) { 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) {