fix worker

This commit is contained in:
Simon Larsen
2022-12-07 11:53:53 +05:30
parent 60eefa0434
commit 5bce49bf2f
11 changed files with 792 additions and 110 deletions

14
.vscode/launch.json vendored
View File

@@ -97,6 +97,20 @@
"restart": true,
"autoAttachChildProcesses": true
},
{
"address": "127.0.0.1",
"localRoot": "${workspaceFolder}/StatusPage",
"name": "Status Page API${cwd}: Debug with Docker",
"port": 9764,
"remoteRoot": "/usr/src/app",
"request": "attach",
"skipFiles": [
"<node_internals>/**"
],
"type": "node",
"restart": true,
"autoAttachChildProcesses": true
},
{
"address": "127.0.0.1",
"localRoot": "${workspaceFolder}/ProbeAPI",

View File

@@ -22,6 +22,10 @@ upstream status-page {
server status-page:3105 weight=10 max_fails=3 fail_timeout=30s;
}
upstream status-page-api {
server status-page:3106 weight=10 max_fails=3 fail_timeout=30s;
}
upstream home {
server home:1444 weight=10 max_fails=3 fail_timeout=30s;
}
@@ -58,6 +62,33 @@ server {
proxy_set_header Connection "upgrade";
proxy_pass http://status-page/;
}
location /status-page-api {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
# enable WebSockets (for ws://sockjs not connected error in the accounts source: https://stackoverflow.com/questions/41381444/websocket-connection-failed-error-during-websocket-handshake-unexpected-respon)
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_pass http://status-page-api/;
}
# Acme Verification.
location /.well-known {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
# enable WebSockets (for ws://sockjs not connected error in the accounts source: https://stackoverflow.com/questions/41381444/websocket-connection-failed-error-during-websocket-handshake-unexpected-respon)
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_pass http://status-page-api/;
}
}
server {

View File

@@ -1 +1 @@
PORT={{ .Env.STATUS_PAGE_PORT }}
PORT={{ .Env.STATUS_PAGE_API_PORT }}

View File

@@ -13,6 +13,7 @@ SHELL ["/bin/bash", "-c"]
RUN npm install typescript -g
RUN npm install ts-node -g
RUN npm install nodemon -g
RUN npm install http-server -g
RUN mkdir /usr/src

View File

@@ -1,10 +1,8 @@
import App from 'CommonServer/Utils/StartServer';
import path from 'path';
import Express, {
ExpressApplication,
ExpressRequest,
ExpressResponse,
ExpressStatic,
} from 'CommonServer/Utils/Express';
import logger from 'CommonServer/Utils/Logger';
import { PostgresAppInstance } from 'CommonServer/Infrastructure/PostgresDatabase';
@@ -20,15 +18,6 @@ export const APP_NAME: string = 'status-page';
const app: ExpressApplication = Express.getExpressApp();
app.use(ExpressStatic(path.join(__dirname, 'public')));
app.use(`/${APP_NAME}`, ExpressStatic(path.join(__dirname, 'public')));
app.use(
[`/${APP_NAME}/assets`, `/${APP_NAME}/${APP_NAME}/assets`],
ExpressStatic(path.join(__dirname, 'dist'))
);
// ACME Challenge Validation.
app.get('/.well-known/acme-challenge/:token', async (
req: ExpressRequest,
@@ -53,7 +42,7 @@ app.get('/.well-known/acme-challenge/:token', async (
return Response.sendTextResponse(req, res, challenge.challenge as string);
});
app.get('/cname-verification/:token', async (
app.get('/status-page-api/cname-verification/:token', async (
req: ExpressRequest,
res: ExpressResponse
) => {
@@ -84,9 +73,6 @@ app.get('/cname-verification/:token', async (
return Response.sendEmptyResponse(req, res);
});
app.get('/*', (_req: ExpressRequest, res: ExpressResponse) => {
res.sendFile(path.join(__dirname, 'public', 'index.html'));
});
const init: Function = async (): Promise<void> => {
try {

5
StatusPage/nodemon.json Normal file
View File

@@ -0,0 +1,5 @@
{
"watch": ["./","../Common", "../CommonServer"],
"ext": "ts,json,tsx,env,js,jsx",
"exec": "node --inspect=0.0.0.0:9229 --require ts-node/register Index.ts"
}

File diff suppressed because it is too large Load Diff

View File

@@ -6,6 +6,7 @@
"Common": "file:../Common",
"CommonServer": "file:../CommonServer",
"CommonUI": "file:../CommonUI",
"http-server": "^14.1.1",
"Model": "file:../Model",
"react": "^18.1.0",
"react-dnd": "^16.0.1",
@@ -19,12 +20,12 @@
"use-async-effect": "^2.2.6"
},
"scripts": {
"dev": "webpack-dev-server --port=3105 --mode=development",
"dev": "webpack-dev-server --port=3105 --mode=development & nodemon &",
"build": "webpack build --mode=production",
"test": "react-app-rewired test",
"eject": "webpack eject",
"compile": "tsc",
"start": "node --require ts-node/register Index.ts",
"start": "node --require ts-node/register Index.ts & http-server ./public -p 3105",
"audit": "npm audit --audit-level=low",
"preinstall": "npx npm-force-resolutions || echo 'No package-lock.json file. Skipping force resolutions'",
"dep-check": "depcheck ./ --skip-missing=true'"

View File

@@ -279,7 +279,7 @@ const checkCnameValidation = (fulldomain: string, token: string): Promise<boolea
https.request({
host: fulldomain,
port: 443,
path: '/cname-verification/' + token,
path: '/status-page-api/cname-verification/' + token,
method: 'GET',
rejectUnauthorized: false,
agent: false

View File

@@ -60,7 +60,6 @@ APIDOCS_ROUTE=/docs
IDENTITY_ROUTE=/identity
FILE_ROUTE=/file
STATUS_PAGE_ROUTE=/status-page
WORKER_ROUTE=/worker
#Ports. Usually they dont need to change.
DASHBOARD_API_PORT=3002
@@ -72,6 +71,7 @@ REALTIME_PORT=3300
WORKERS_PORT=3452
ACCOUNTS_PORT=3003
STATUS_PAGE_PORT=3105
STATUS_PAGE_API_PORT=3106
DASHBOARD_PORT=3009
# Internal SMTP Server - Haraka

View File

@@ -140,6 +140,10 @@ services:
status-page:
ports:
- '3105:3105'
- '3106:3106'
{{ if eq .Env.ENVIRONMENT "development" }}
- 9764:9229 # Debugging port.
{{ end }}
{{ if or (eq .Env.ENVIRONMENT "development") (eq .Env.ENVIRONMENT "ci") }}
build:
network: host