function printAppControlData(id: string) {
let reqAppControl = global.tizen.application.getCurrentApplication().getRequestedAppControl();
if (reqAppControl) {
- console.log(`id: ${id}, appControlData operation: ${reqAppControl.appControl.operation}`);
+ console.debug(`id: ${id}, appControlData operation: ${reqAppControl.appControl.operation}`);
let appControlData = reqAppControl.appControl.data;
for (let dataIndex in appControlData) {
for (let valueIndex in appControlData[dataIndex].value)
- console.log(`data[${dataIndex}][${valueIndex}]: ${appControlData[dataIndex].value[valueIndex]}`);
+ console.debug(`data[${dataIndex}][${valueIndex}]: ${appControlData[dataIndex].value[valueIndex]}`);
}
}
}
function registerExtensionResolver(id: string) {
if (wrt.tv) {
let extensionResolver = (module: any, file_path: string) => {
- console.log(`resolved path: ${file_path}`);
+ console.debug(`resolved path: ${file_path}`);
let content = (wrt.tv as NativeWRTjs.TVExtension).decryptFile(id, file_path);
if (content) {
// Remove BOM
if (!periodLauncherAlive) {
periodLauncherAlive = 20;
if (!wrt.checkLauncherAlive(id)) {
- console.log(`${id} launcher was killed.`)
+ console.debug(`${id} launcher was killed.`)
requestStopService(id);
checkLauncherAlive = () => {};
}
}
export function start(id: string, filename: string) {
+ let ids = id.split(':');
+ let serviceId = ids[0];
+ let packageId = wrt.getPackageId(id);
+ if (!packageId) {
+ console.debug(`${id}'s pkgid is empty, so stop service`);
+ requestStopService(id);
+ return;
+ }
wrt.setServiceAppId(id);
+ wrt.security?.dropThreadPrivilege(packageId, serviceId);
+
XWalkExtension.initialize();
XWalkExtension.setRuntimeMessageHandler((type, data) => {
if (type === 'tizen://exit') {
- console.log(`${id} will be closed by ${type}`);
+ console.debug(`${id} will be closed by ${type}`);
requestStopService(id);
}
});
- console.log(`serviceType : ${global['serviceType']}`)
+ console.debug(`serviceType : ${global['serviceType']}`)
new DeviceAPIRouter(id, isGlobalService());
-
- // this is workaround solution to make webapis singleton worker
- // ahead of dropThreadPrivilege()
- global.tizen.systeminfo.getPropertyValue("CPU", () => { }, () => { });
+ printAppControlData(id);
// This is for awaking up uv loop.
- dummyTimer = setInterval(() => {
- checkLauncherAlive(id);
- }, 100);
+ if (isGlobalService()) {
+ dummyTimer = setInterval(() => {
+ checkLauncherAlive(id);
+ }, 100);
+ }
if (isServiceApplication()) {
registerExtensionResolver(id);
filename = wrt.getStartServiceFile(id);
- console.log(`start global service file: ${filename}`);
+ console.debug(`start global service file: ${filename}`);
}
try {
- let ids = id.split(':');
- let serviceId = ids[0];
- let packageId = global.webapis.getPackageId();
- wrt.security?.dropThreadPrivilege(packageId, serviceId);
- printAppControlData(id);
-
app = require(filename);
if (app.onStart !== undefined) {
app.onStart();
if (app.onRequest !== undefined) {
app.onRequest();
}
+ } catch (e) {
+ console.debug(`exception on start: ${e}`);
+ requestStopService(id);
+ } finally {
if (isGlobalService()) {
wrt.finishStartingService(id);
}
- } catch (e) {
- console.log(`exception on start: ${e}`);
- requestStopService(id);
}
}
app.onExit();
}
} catch (e) {
- console.log(`exception on stop: ${e}`);
+ console.debug(`exception on stop: ${e}`);
}
}
function run() {
let id = workerData.id;
- // FIXME: this should be 'wrt.tv?.serviceMount(id)' after Tizen 6.5 release
- (wrt.tv as any)?.serviceMount(id);
+ if (!id) {
+ console.debug('workerData.id is empty!');
+ process.exit();
+ }
+ Object.defineProperty(global, 'internalId', {
+ value: id,
+ writable: false
+ });
+
+ wrt.tv?.serviceMount(id);
let filename = workerData.filename;
start(id, filename);
- if (!parentPort)
- return;
- parentPort.on('message', (message) => {
- console.log(`Received message type : ${message.type}`);
+ parentPort?.on('message', (message) => {
+ console.debug(`Received message type : ${message.type}`);
if (message.type === 'wake') {
app?.onRequest();
} else if (message.type === 'stop') {
setTimeout(() => {
XWalkExtension.cleanup();
parentPort?.postMessage("will-terminate");
- (wrt.tv as any)?.serviceUmount(id);
+ parentPort?.close();
+ wrt.tv?.serviceUmount(id);
}, message.delay);
}
});