51 lines
1.1 KiB
JavaScript
51 lines
1.1 KiB
JavaScript
process.parentPort?.on('message', (message) => {
|
|
const payload = message?.data || message || {};
|
|
if (payload.type === 'ping') {
|
|
process.parentPort.postMessage({
|
|
type: 'pong',
|
|
worker: 'business-workflow-utility',
|
|
pid: process.pid,
|
|
capabilities: [
|
|
'clip.compose',
|
|
'subtitle.generate',
|
|
'ffmpeg.transform',
|
|
'social.publish',
|
|
],
|
|
});
|
|
return;
|
|
}
|
|
process.parentPort.postMessage({
|
|
type: 'ack',
|
|
worker: 'business-workflow-utility',
|
|
pid: process.pid,
|
|
received: payload,
|
|
});
|
|
});
|
|
|
|
process.on('message', (payload) => {
|
|
if (payload?.type === 'ping') {
|
|
process.send?.({
|
|
type: 'pong',
|
|
worker: 'business-workflow-utility',
|
|
pid: process.pid,
|
|
capabilities: [
|
|
'clip.compose',
|
|
'subtitle.generate',
|
|
'ffmpeg.transform',
|
|
'social.publish',
|
|
],
|
|
});
|
|
return;
|
|
}
|
|
process.send?.({
|
|
type: 'ack',
|
|
worker: 'business-workflow-utility',
|
|
pid: process.pid,
|
|
received: payload,
|
|
});
|
|
});
|
|
|
|
setInterval(() => {
|
|
// Keep the isolated worker alive while the local runtime is using it.
|
|
}, 30_000);
|