UNPKG

@pmouli/isy-matter-server

Version:

Service to expose an ISY device as a Matter Border router

34 lines 1.76 kB
import { fork } from 'child_process'; import { Command } from 'commander'; import path from 'path'; const program = new Command(); program.option('-a, --autoStart', 'Start matter bridge server on startup', false).option('-l, --dependencies', 'Load dependencies - static (from local node_modules), plugin (from plugin node_modules)', 'static').option('-e, --env [PATH]', 'Path to environment file', '.env').option('-d, --devices <DEVICES>', 'list of device (addresses) to expose', []).option('--filter [FILTER]', 'devices names to exclude', '').option('-r, --requireAuth', 'Require authentication to start bridge server', false).option('-s, --openSocket', 'Open socket to receive requests from plugin/client', false).option('-f, --factoryReset', 'Reset bridge server to initial state', false).option('-p --subprocess', 'run as subprocess', false); program.parse(); const options = program.opts(); if (options.subprocess) { console.log('Running as subprocess'); startChildProcess(); } else { console.log('Running as main process'); // This is the main entry point for the Matter server. await import('./server.js'); } // This is the main entry point for the Matter server. function startChildProcess() { const cp = fork(path.resolve('bin/server.js'), process.argv.slice(1)); cp.on('message', (msg) => { console.log('Message from child process:', msg); }); cp.on('close', (code) => { console.log(`Child process exited with code ${code}. Restarting...`); // Restart the child process startChildProcess(); }); cp.on('exit', (code) => { console.log(`Child process exited with code ${code}`); process.exit(code); }); return cp; } //# sourceMappingURL=entrypoint.js.map