adding file polling for windows machines

This commit is contained in:
2024-11-15 14:38:53 -07:00
parent 3725d40e6e
commit d689b4b684
5 changed files with 25 additions and 5 deletions

View File

@@ -31,6 +31,7 @@ const sampleCompose = `services:
- .env # needs to have your CANVAS_TOKEN set
environment:
- TZ=America/Denver # prevents timezone issues for due dates
# - FILE_POLLING=true # increases cpu usage, uncomment if source volumes are on ntfs
volumes:
- ~/projects/faculty/1430/2024-fall-alex/modules:/app/storage/UX
- ~/projects/faculty/4850_AdvancedFE/2024-fall-alex/modules:/app/storage/advanced_frontend

View File

@@ -3,6 +3,8 @@ import next from "next";
import { Server } from "socket.io";
import chokidar from "chokidar";
import path from "path";
import dotenv from "dotenv";
dotenv.config();
const dev = process.env.NODE_ENV !== "production";
const hostname = "localhost";
@@ -14,12 +16,18 @@ const handler = app.getRequestHandler();
const folderToWatch = path.join(process.cwd(), "./storage", "/");
console.log("watching folder", folderToWatch);
const usePolling = process.env.FILE_POLLING === "true";
console.log("FILE_POLLING:", usePolling);
const watcher = chokidar.watch(folderToWatch, {
persistent: true,
usePolling,
});
app.prepare().then(() => {
const httpServer = createServer(handler);
const io = new Server(httpServer);
const watcher = chokidar.watch(folderToWatch, { persistent: true });
io.on("connection", (socket) => {
console.log("websocket connection created");