diff --git a/Dockerfile b/Dockerfile index eab3c4419..51b562f7d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -43,8 +43,6 @@ RUN mkdir -p /var/cache/nginx && \ COPY --from=builder /app/apps/nextjs/next.config.ts . COPY --from=builder /app/apps/nextjs/package.json . -COPY --from=builder /app/apps/tasks/tasks.cjs ./apps/tasks/tasks.cjs -COPY --from=builder /app/apps/websocket/wssServer.cjs ./apps/websocket/wssServer.cjs COPY --from=builder /app/node_modules/better-sqlite3/build/Release/better_sqlite3.node /app/build/better_sqlite3.node COPY --from=builder /app/packages/db/migrations ./db/migrations diff --git a/apps/nextjs/package.json b/apps/nextjs/package.json index 92538095f..4a7323606 100644 --- a/apps/nextjs/package.json +++ b/apps/nextjs/package.json @@ -44,9 +44,11 @@ "@homarr/server-settings": "workspace:^0.1.0", "@homarr/settings": "workspace:^0.1.0", "@homarr/spotlight": "workspace:^0.1.0", + "@homarr/tasks": "workspace:^0.1.0", "@homarr/translation": "workspace:^0.1.0", "@homarr/ui": "workspace:^0.1.0", "@homarr/validation": "workspace:^0.1.0", + "@homarr/websocket": "workspace:^0.1.0", "@homarr/widgets": "workspace:^0.1.0", "@mantine/colors-generator": "catalog:", "@mantine/core": "catalog:", diff --git a/apps/nextjs/src/instrumentation.ts b/apps/nextjs/src/instrumentation.ts new file mode 100644 index 000000000..19a2865b7 --- /dev/null +++ b/apps/nextjs/src/instrumentation.ts @@ -0,0 +1,6 @@ +export async function register() { + if (process.env.NEXT_RUNTIME === "nodejs") { + await import("@homarr/tasks"); + await import("@homarr/websocket"); + } +} diff --git a/apps/tasks/package.json b/apps/tasks/package.json index 3cb918df5..e44dda008 100644 --- a/apps/tasks/package.json +++ b/apps/tasks/package.json @@ -5,12 +5,11 @@ "license": "Apache-2.0", "type": "module", "exports": { - ".": "./src/index.ts" + ".": "./src/main.ts" }, "main": "./src/main.ts", "types": "./src/main.ts", "scripts": { - "build": "esbuild src/main.ts --bundle --platform=node --loader:.scss=text --external:*.node --external:@opentelemetry/api --external:deasync --external:bcrypt --outfile=tasks.cjs", "clean": "rm -rf .turbo node_modules", "dev": "pnpm with-env tsx ./src/main.ts", "format": "prettier --check . --ignore-path ../../.gitignore", diff --git a/apps/websocket/package.json b/apps/websocket/package.json index 8fe731bcb..c4a9cf9d0 100644 --- a/apps/websocket/package.json +++ b/apps/websocket/package.json @@ -4,10 +4,12 @@ "private": true, "license": "Apache-2.0", "type": "module", + "exports": { + ".": "./src/main.ts" + }, "main": "./src/main.ts", "types": "./src/main.ts", "scripts": { - "build": "esbuild src/main.ts --bundle --platform=node --outfile=wssServer.cjs --external:bcrypt --external:@opentelemetry/api --external:deasync --external:cpu-features --loader:.html=text --loader:.scss=text --loader:.node=text", "clean": "rm -rf .turbo node_modules", "dev": "pnpm with-env tsx ./src/main.ts", "format": "prettier --check . --ignore-path ../../.gitignore", diff --git a/package.json b/package.json index c9ea46f32..e32fd69c4 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "db:migration:sqlite:run": "pnpm -F db migration:sqlite:run", "db:push": "pnpm -F db push:sqlite", "db:studio": "pnpm -F db studio", - "dev": "turbo dev --parallel", + "dev": "pnpm -F nextjs dev", "docker:dev": "docker compose -f ./development/development.docker-compose.yml up", "format": "turbo format --continue -- --cache --cache-location node_modules/.cache/.prettiercache", "format:fix": "turbo format --continue -- --write --cache --cache-location node_modules/.cache/.prettiercache", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 021aa003f..290e776d5 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -754,6 +754,9 @@ importers: '@homarr/spotlight': specifier: workspace:^0.1.0 version: link:../../packages/spotlight + '@homarr/tasks': + specifier: workspace:^0.1.0 + version: link:../tasks '@homarr/translation': specifier: workspace:^0.1.0 version: link:../../packages/translation @@ -763,6 +766,9 @@ importers: '@homarr/validation': specifier: workspace:^0.1.0 version: link:../../packages/validation + '@homarr/websocket': + specifier: workspace:^0.1.0 + version: link:../websocket '@homarr/widgets': specifier: workspace:^0.1.0 version: link:../../packages/widgets diff --git a/scripts/run.sh b/scripts/run.sh index 4d90499d5..12e638fa7 100644 --- a/scripts/run.sh +++ b/scripts/run.sh @@ -43,21 +43,13 @@ else REDIS_PID=$! fi - - -node apps/tasks/tasks.cjs & -TASKS_PID=$! - -node apps/websocket/wssServer.cjs & -WSS_PID=$! - node apps/nextjs/server.js & NEXTJS_PID=$! # Function to handle SIGTERM and shut down services terminate() { echo "Received SIGTERM. Shutting down..." - kill -TERM $NGINX_PID $TASKS_PID $WSS_PID $NEXTJS_PID 2>/dev/null + kill -TERM $NGINX_PID $NEXTJS_PID 2>/dev/null wait # kill redis-server last because of logging of other services and only if $REDIS_PID is set if [ -n "$REDIS_PID" ]; then