From d9ab1bd27d32160de1580393b1be67060b0a17f7 Mon Sep 17 00:00:00 2001 From: DongHyun Song Date: Wed, 10 Mar 2021 18:09:59 +0900 Subject: [PATCH] [Service] Check launcher process Check launcher process if it is alive, otherwise stop the service. Related chromium-efl patch: https://review.tizen.org/gerrit/#/c/platform/framework/web/chromium-efl/+/247802/ Change-Id: Iac686bcf5ecc5acaec69599f11571a00f137de22 Signed-off-by: DongHyun Song --- wrt_app/common/service_runner.ts | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/wrt_app/common/service_runner.ts b/wrt_app/common/service_runner.ts index f372d96..4c62afb 100644 --- a/wrt_app/common/service_runner.ts +++ b/wrt_app/common/service_runner.ts @@ -51,7 +51,20 @@ let requestStopService = (id: string) => { } let app: any = null; -let fakeTimer: any; +let dummyTimer: any; +let periodLauncherAlive = 20; // 2s + +let checkLauncherAlive = (id: string) => { + periodLauncherAlive--; + if (!periodLauncherAlive) { + periodLauncherAlive = 20; + if (!wrt.checkLauncherAlive(id)) { + console.log(`${id} launcher was killed.`) + requestStopService(id); + checkLauncherAlive = () => {}; + } + } +} export function start(id: string, filename: string) { XWalkExtension.initialize(); @@ -71,9 +84,10 @@ export function start(id: string, filename: string) { console.log(`start global service file: ${filename}`); } - // FIXME: this is for awaking up uv loop. - // uv loop is sleeping for a few second with tizen webapis's aync callback - fakeTimer = setInterval(() => {}, 100); + // This is for awaking up uv loop. + dummyTimer = setInterval(() => { + checkLauncherAlive(id); + }, 100); printAppControlData(id); try { @@ -99,8 +113,8 @@ export function start(id: string, filename: string) { } export function stop(id: string) { - if (fakeTimer) - clearInterval(fakeTimer); + if (dummyTimer) + clearInterval(dummyTimer); try { if (app.onStop !== undefined) { app.onStop(); -- 2.7.4