}
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();
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 {
}
export function stop(id: string) {
- if (fakeTimer)
- clearInterval(fakeTimer);
+ if (dummyTimer)
+ clearInterval(dummyTimer);
try {
if (app.onStop !== undefined) {
app.onStop();