29 lines
801 B
JavaScript
Executable File
29 lines
801 B
JavaScript
Executable File
#!/usr/bin/env node
|
|
import { FilesystemWatcher, configFromEnv } from "./watcher.mjs";
|
|
|
|
const cliArgs = process.argv.slice(2);
|
|
const envCfg = configFromEnv(process.env);
|
|
|
|
const roots = cliArgs.length > 0 ? cliArgs : envCfg.roots;
|
|
if (!roots || roots.length === 0) {
|
|
process.stderr.write(
|
|
"agentmemory-fs-watcher: no directories to watch.\n" +
|
|
"Usage: agentmemory-fs-watcher <dir> [<dir>...]\n" +
|
|
"Or set AGENTMEMORY_FS_WATCH_DIRS=path1,path2\n",
|
|
);
|
|
process.exit(2);
|
|
}
|
|
|
|
const watcher = new FilesystemWatcher({ ...envCfg, roots });
|
|
watcher.start();
|
|
process.stderr.write(
|
|
`[fs-watcher] emitting to ${envCfg.baseUrl || "http://localhost:3111"}\n`,
|
|
);
|
|
|
|
const shutdown = () => {
|
|
watcher.stop();
|
|
process.exit(0);
|
|
};
|
|
process.on("SIGINT", shutdown);
|
|
process.on("SIGTERM", shutdown);
|