Add polling fallback for Docker file watcher reliability
File watchers (inotify) don't work reliably with Docker bind mounts, so add 5-second polling as a fallback to ensure task updates are detected in containerized environments. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
b3e055217d
commit
24757f5031
|
|
@ -157,6 +157,58 @@ export class BacklogAggregator {
|
|||
|
||||
// Set up periodic rescan for new projects
|
||||
setInterval(() => this.scanForProjects(), 60000); // Every minute
|
||||
|
||||
// Set up periodic task polling as fallback for Docker environments
|
||||
// where inotify may not work reliably across bind mounts
|
||||
setInterval(() => this.pollAllTasks(), 5000); // Every 5 seconds
|
||||
}
|
||||
|
||||
private async pollAllTasks(): Promise<void> {
|
||||
let hasChanges = false;
|
||||
const previousTaskCount = this.tasks.size;
|
||||
|
||||
for (const [projectPath] of this.projects) {
|
||||
const project = this.projects.get(projectPath);
|
||||
if (!project) continue;
|
||||
|
||||
const tasksPath = join(projectPath, "backlog", "tasks");
|
||||
try {
|
||||
const entries = await readdir(tasksPath, { withFileTypes: true });
|
||||
for (const entry of entries) {
|
||||
if (!entry.isFile() || !entry.name.endsWith(".md")) continue;
|
||||
|
||||
const taskPath = join(tasksPath, entry.name);
|
||||
try {
|
||||
const content = await readFile(taskPath, "utf-8");
|
||||
const task = parseTask(content, taskPath);
|
||||
if (task) {
|
||||
const key = `${projectPath}:${task.id}`;
|
||||
const existing = this.tasks.get(key);
|
||||
|
||||
// Check if task is new or changed
|
||||
if (!existing || existing.rawContent !== task.rawContent || existing.status !== task.status) {
|
||||
const aggregatedTask: AggregatedTask = {
|
||||
...task,
|
||||
projectName: project.name,
|
||||
projectColor: project.color,
|
||||
projectPath: projectPath,
|
||||
};
|
||||
this.tasks.set(key, aggregatedTask);
|
||||
hasChanges = true;
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
// File read error
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
// Directory read error
|
||||
}
|
||||
}
|
||||
|
||||
if (hasChanges || this.tasks.size !== previousTaskCount) {
|
||||
this.broadcastUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
async stop(): Promise<void> {
|
||||
|
|
|
|||
Loading…
Reference in New Issue