Revert "[Service] Refactor stop service sequence" 21/245621/1
authorDongHyun Song <dh81.song@samsung.com>
Tue, 13 Oct 2020 08:14:25 +0000 (08:14 +0000)
committerDongHyun Song <dh81.song@samsung.com>
Tue, 13 Oct 2020 08:14:25 +0000 (08:14 +0000)
This reverts commit dd79b18738cdb66f003a5195e78b5ff03248e27e.

Change-Id: If6ff1a847e9aeed86faf9fd9fc014971c339096f

wrt_app/common/service_manager.ts
wrt_app/common/service_runner.ts
wrt_app/service/builtins/wasm_builder.ts

index beb3d6e..c4b2940 100644 (file)
@@ -43,13 +43,7 @@ export function startService(id: string, filename: string) {
   console.log(`startService - ${id}`);
   if (isMainThread) {
     let startService = `${__dirname}/service_runner.js`;
-    let worker = createWorker(id, startService, filename);
-    worker.on('message', (message: any) => {
-      if (message.type === 'stop') {
-        console.log(`${id} will shutdown after ${message.delay}ms`);
-        setTimeout(() => wrt.stopService(id), message.delay);
-      }
-    });
+    createWorker(id, startService, filename);
   }
 }
 
@@ -70,11 +64,8 @@ export function handleBuiltinService(serviceId: string, serviceName: string) {
       console.log(`Builtin service is ${serviceName}`);
       let startService = `${__dirname}/../service/builtins/${serviceName}.js`;
       let worker = createWorker(serviceId, startService, '');
-      worker.on('message', (message: any) => {
-        if (message.type === 'stop') {
-          console.log(`${serviceName} built-in service will be stopped`);
-          terminateWorker(serviceId, message.delay);
-        }
+      worker.on('stop', () => {
+        terminateWorker(serviceId, 0);
       });
     }
   }
index c86829c..43681b5 100644 (file)
@@ -31,18 +31,13 @@ function registerExtensionResolver(id: string) {
   }
 }
 
-function requestStopService(delay: number) {
-  if (parentPort) {
-    parentPort.postMessage({type: 'stop', delay: delay});
-  }
-}
-
 let app: any = null;
 export function start(id: string, filename: string) {
   XWalkExtension.initialize();
   XWalkExtension.setRuntimeMessageHandler((type, data) => {
     if (type === 'tizen://exit') {
-      requestStopService(500);
+      console.log(`${id} will be closed by ${type}`);
+      setTimeout(() => wrt.stopService(id), 500);
     }
   });
 
@@ -71,7 +66,7 @@ export function start(id: string, filename: string) {
     }
   } catch (e) {
     console.log(`exception on start: ${e}`);
-    requestStopService(500);
+    setTimeout(() => wrt.stopService(id), 500);
   }
 }
 
index 6f6c5b1..7ec30a3 100644 (file)
@@ -26,7 +26,7 @@ export function run(app_id: string) {
     compileWasmForCaching(file_path);
   });
   if (parentPort) {
-    parentPort.postMessage({type: 'stop', delay: 0});
+    parentPort.postMessage('stop');
   }
 }