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

@@ -10,6 +10,7 @@ services:
environment: environment:
- storageDirectory=/app/storage - storageDirectory=/app/storage
- TZ=America/Denver - TZ=America/Denver
# - FILE_POLLING=true
volumes: volumes:
- ~/projects/faculty/1430/2024-fall-alex/modules:/app/storage/UX - ~/projects/faculty/1430/2024-fall-alex/modules:/app/storage/UX
- ~/projects/faculty/4850_AdvancedFE/2024-fall-alex/modules:/app/storage/advanced_frontend - ~/projects/faculty/4850_AdvancedFE/2024-fall-alex/modules:/app/storage/advanced_frontend

View File

@@ -19,6 +19,7 @@
"@trpc/server": "11.0.0-rc.608", "@trpc/server": "11.0.0-rc.608",
"@types/ws": "^8.5.13", "@types/ws": "^8.5.13",
"chokidar": "^4.0.1", "chokidar": "^4.0.1",
"dotenv": "^16.4.5",
"jsdom": "^25.0.0", "jsdom": "^25.0.0",
"next": "^15.0.2", "next": "^15.0.2",
"react": "^18", "react": "^18",
@@ -32,7 +33,6 @@
"@monaco-editor/loader": "^1.4.0", "@monaco-editor/loader": "^1.4.0",
"@monaco-editor/react": "^4.6.0", "@monaco-editor/react": "^4.6.0",
"@testing-library/dom": "^10.4.0", "@testing-library/dom": "^10.4.0",
"socket.io-client": "^4.8.1",
"@testing-library/react": "^16.0.0", "@testing-library/react": "^16.0.0",
"@types/node": "^22", "@types/node": "^22",
"@types/react": "^18", "@types/react": "^18",
@@ -46,6 +46,7 @@
"postcss": "^8", "postcss": "^8",
"react-error-boundary": "^4.0.13", "react-error-boundary": "^4.0.13",
"react-hot-toast": "^2.4.1", "react-hot-toast": "^2.4.1",
"socket.io-client": "^4.8.1",
"tailwindcss": "^3.4.1", "tailwindcss": "^3.4.1",
"typescript": "^5", "typescript": "^5",
"vitest": "^2.0.5", "vitest": "^2.0.5",

15
nextjs/pnpm-lock.yaml generated
View File

@@ -29,6 +29,9 @@ importers:
chokidar: chokidar:
specifier: ^4.0.1 specifier: ^4.0.1
version: 4.0.1 version: 4.0.1
dotenv:
specifier: ^16.4.5
version: 16.4.5
jsdom: jsdom:
specifier: ^25.0.0 specifier: ^25.0.0
version: 25.0.1 version: 25.0.1
@@ -44,9 +47,6 @@ importers:
socket.io: socket.io:
specifier: ^4.8.1 specifier: ^4.8.1
version: 4.8.1 version: 4.8.1
socket.io-client:
specifier: ^4.8.1
version: 4.8.1
superjson: superjson:
specifier: ^2.2.1 specifier: ^2.2.1
version: 2.2.1 version: 2.2.1
@@ -105,6 +105,9 @@ importers:
react-hot-toast: react-hot-toast:
specifier: ^2.4.1 specifier: ^2.4.1
version: 2.4.1(csstype@3.1.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) version: 2.4.1(csstype@3.1.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
socket.io-client:
specifier: ^4.8.1
version: 4.8.1
tailwindcss: tailwindcss:
specifier: ^3.4.1 specifier: ^3.4.1
version: 3.4.14(ts-node@10.9.2(@types/node@22.9.0)(typescript@5.6.3)) version: 3.4.14(ts-node@10.9.2(@types/node@22.9.0)(typescript@5.6.3))
@@ -1256,6 +1259,10 @@ packages:
dompurify@3.1.7: dompurify@3.1.7:
resolution: {integrity: sha512-VaTstWtsneJY8xzy7DekmYWEOZcmzIe3Qb3zPd4STve1OBTa+e+WmS1ITQec1fZYXI3HCsOZZiSMpG6oxoWMWQ==} resolution: {integrity: sha512-VaTstWtsneJY8xzy7DekmYWEOZcmzIe3Qb3zPd4STve1OBTa+e+WmS1ITQec1fZYXI3HCsOZZiSMpG6oxoWMWQ==}
dotenv@16.4.5:
resolution: {integrity: sha512-ZmdL2rui+eB2YwhsWzjInR8LldtZHGDoQ1ugH85ppHKwpUHL7j7rN0Ti9NCnGiQbhaZ11FpR+7ao1dNsmduNUg==}
engines: {node: '>=12'}
eastasianwidth@0.2.0: eastasianwidth@0.2.0:
resolution: {integrity: sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==} resolution: {integrity: sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==}
@@ -3801,6 +3808,8 @@ snapshots:
dompurify@3.1.7: {} dompurify@3.1.7: {}
dotenv@16.4.5: {}
eastasianwidth@0.2.0: {} eastasianwidth@0.2.0: {}
electron-to-chromium@1.5.53: {} electron-to-chromium@1.5.53: {}

View File

@@ -31,6 +31,7 @@ const sampleCompose = `services:
- .env # needs to have your CANVAS_TOKEN set - .env # needs to have your CANVAS_TOKEN set
environment: environment:
- TZ=America/Denver # prevents timezone issues for due dates - TZ=America/Denver # prevents timezone issues for due dates
# - FILE_POLLING=true # increases cpu usage, uncomment if source volumes are on ntfs
volumes: volumes:
- ~/projects/faculty/1430/2024-fall-alex/modules:/app/storage/UX - ~/projects/faculty/1430/2024-fall-alex/modules:/app/storage/UX
- ~/projects/faculty/4850_AdvancedFE/2024-fall-alex/modules:/app/storage/advanced_frontend - ~/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 { Server } from "socket.io";
import chokidar from "chokidar"; import chokidar from "chokidar";
import path from "path"; import path from "path";
import dotenv from "dotenv";
dotenv.config();
const dev = process.env.NODE_ENV !== "production"; const dev = process.env.NODE_ENV !== "production";
const hostname = "localhost"; const hostname = "localhost";
@@ -14,12 +16,18 @@ const handler = app.getRequestHandler();
const folderToWatch = path.join(process.cwd(), "./storage", "/"); const folderToWatch = path.join(process.cwd(), "./storage", "/");
console.log("watching folder", folderToWatch); 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(() => { app.prepare().then(() => {
const httpServer = createServer(handler); const httpServer = createServer(handler);
const io = new Server(httpServer); const io = new Server(httpServer);
const watcher = chokidar.watch(folderToWatch, { persistent: true });
io.on("connection", (socket) => { io.on("connection", (socket) => {
console.log("websocket connection created"); console.log("websocket connection created");