mirror of
https://github.com/OneUptime/oneuptime
synced 2024-11-21 22:59:07 +00:00
refactor: Update npm dependency to latest stable version
This commit is contained in:
parent
1ed2548be2
commit
ba97a1e14b
@ -65,6 +65,35 @@ export default class LocalFile {
|
||||
);
|
||||
}
|
||||
|
||||
public static async getListOfDirectories(path: string): Promise<string[]> {
|
||||
return new Promise(
|
||||
(
|
||||
resolve: (directories: string[]) => void,
|
||||
reject: PromiseRejectErrorFunction,
|
||||
) => {
|
||||
fs.readdir(
|
||||
path,
|
||||
{ withFileTypes: true },
|
||||
(err: Error | null, files: fs.Dirent[]) => {
|
||||
if (err) {
|
||||
return reject(err);
|
||||
}
|
||||
|
||||
const directories: string[] = files
|
||||
.filter((file: fs.Dirent) => {
|
||||
return file.isDirectory();
|
||||
})
|
||||
.map((file: fs.Dirent) => {
|
||||
return file.name;
|
||||
});
|
||||
|
||||
resolve(directories);
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
public static async doesFileExist(path: string): Promise<boolean> {
|
||||
return new Promise(
|
||||
(
|
||||
|
@ -42,7 +42,7 @@ spec:
|
||||
httpGet:
|
||||
path: /status/live
|
||||
port: {{ $.Values.port.app }}
|
||||
initialDelaySeconds: 30
|
||||
initialDelaySeconds: 300
|
||||
periodSeconds: 10
|
||||
timeoutSeconds: 30
|
||||
# Readyness Probe
|
||||
@ -50,7 +50,7 @@ spec:
|
||||
httpGet:
|
||||
path: /status/ready
|
||||
port: {{ $.Values.port.app }}
|
||||
initialDelaySeconds: 30
|
||||
initialDelaySeconds: 300
|
||||
periodSeconds: 10
|
||||
timeoutSeconds: 30
|
||||
{{- if $.Values.containerSecurityContext }}
|
||||
|
@ -51,17 +51,17 @@ spec:
|
||||
httpGet:
|
||||
path: /status/live
|
||||
port: {{ $.Values.port.ingestor }}
|
||||
initialDelaySeconds: 30
|
||||
periodSeconds: 15
|
||||
timeoutSeconds: 60
|
||||
initialDelaySeconds: 300
|
||||
periodSeconds: 10
|
||||
timeoutSeconds: 30
|
||||
# Readyness Probe
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: /status/ready
|
||||
port: {{ $.Values.port.ingestor }}
|
||||
initialDelaySeconds: 30
|
||||
periodSeconds: 15
|
||||
timeoutSeconds: 60
|
||||
initialDelaySeconds: 300
|
||||
periodSeconds: 10
|
||||
timeoutSeconds: 30
|
||||
{{- if $.Values.containerSecurityContext }}
|
||||
securityContext: {{- $.Values.containerSecurityContext | toYaml | nindent 12 }}
|
||||
{{- end }}
|
||||
|
@ -56,7 +56,7 @@ spec:
|
||||
httpGet:
|
||||
path: /status/live
|
||||
port: 7851
|
||||
initialDelaySeconds: 30
|
||||
initialDelaySeconds: 300
|
||||
periodSeconds: 10
|
||||
timeoutSeconds: 30
|
||||
# Readyness Probe
|
||||
@ -64,7 +64,7 @@ spec:
|
||||
httpGet:
|
||||
path: /status/ready
|
||||
port: 7851
|
||||
initialDelaySeconds: 30
|
||||
initialDelaySeconds: 300
|
||||
periodSeconds: 10
|
||||
timeoutSeconds: 30
|
||||
volumeMounts:
|
||||
|
@ -78,7 +78,7 @@ ENV PRODUCTION=true
|
||||
|
||||
WORKDIR /usr/src/app
|
||||
|
||||
RUN npx playwright install
|
||||
RUN npx playwright install --with-deps
|
||||
|
||||
# Install app dependencies
|
||||
COPY ./Probe/package*.json /usr/src/app/
|
||||
|
@ -8,6 +8,7 @@ import ObjectID from "Common/Types/ObjectID";
|
||||
import logger from "CommonServer/Utils/Logger";
|
||||
import VMRunner from "CommonServer/Utils/VM/VMRunner";
|
||||
import { Browser, Page, chromium, firefox } from "playwright";
|
||||
import LocalFile from "CommonServer/Utils/LocalFile";
|
||||
|
||||
export interface SyntheticMonitorOptions {
|
||||
monitorId?: ObjectID | undefined;
|
||||
@ -186,6 +187,66 @@ export default class SyntheticMonitor {
|
||||
return { height: viewPortHeight, width: viewPortWidth };
|
||||
}
|
||||
|
||||
public static async getChromeExecutablePath(): Promise<string> {
|
||||
const doesDirectoryExist: boolean = await LocalFile.doesDirectoryExist(
|
||||
"/root/.cache/ms-playwright",
|
||||
);
|
||||
if (!doesDirectoryExist) {
|
||||
throw new BadDataException("Chrome executable path not found.");
|
||||
}
|
||||
|
||||
// get list of files in the directory
|
||||
const directories: string[] = await LocalFile.getListOfDirectories(
|
||||
"/root/.cache/ms-playwright",
|
||||
);
|
||||
|
||||
if (directories.length === 0) {
|
||||
throw new BadDataException("Chrome executable path not found.");
|
||||
}
|
||||
|
||||
const chromeInstallationName: string | undefined = directories.find(
|
||||
(directory: string) => {
|
||||
return directory.includes("chromium");
|
||||
},
|
||||
);
|
||||
|
||||
if (!chromeInstallationName) {
|
||||
throw new BadDataException("Chrome executable path not found.");
|
||||
}
|
||||
|
||||
return `/root/.cache/ms-playwright/${chromeInstallationName}/chrome-linux/chrome`;
|
||||
}
|
||||
|
||||
public static async getFirefoxExecutablePath(): Promise<string> {
|
||||
const doesDirectoryExist: boolean = await LocalFile.doesDirectoryExist(
|
||||
"/root/.cache/ms-playwright",
|
||||
);
|
||||
if (!doesDirectoryExist) {
|
||||
throw new BadDataException("Firefox executable path not found.");
|
||||
}
|
||||
|
||||
// get list of files in the directory
|
||||
const directories: string[] = await LocalFile.getListOfDirectories(
|
||||
"/root/.cache/ms-playwright",
|
||||
);
|
||||
|
||||
if (directories.length === 0) {
|
||||
throw new BadDataException("Firefox executable path not found.");
|
||||
}
|
||||
|
||||
const firefoxInstallationName: string | undefined = directories.find(
|
||||
(directory: string) => {
|
||||
return directory.includes("firefox");
|
||||
},
|
||||
);
|
||||
|
||||
if (!firefoxInstallationName) {
|
||||
throw new BadDataException("Firefox executable path not found.");
|
||||
}
|
||||
|
||||
return `/root/.cache/ms-playwright/${firefoxInstallationName}/firefox/firefox`;
|
||||
}
|
||||
|
||||
private static async getPageByBrowserType(data: {
|
||||
browserType: BrowserType;
|
||||
screenSizeType: ScreenSizeType;
|
||||
@ -204,12 +265,16 @@ export default class SyntheticMonitor {
|
||||
let browser: Browser | null = null;
|
||||
|
||||
if (data.browserType === BrowserType.Chromium) {
|
||||
browser = await chromium.launch();
|
||||
browser = await chromium.launch({
|
||||
executablePath: await this.getChromeExecutablePath(),
|
||||
});
|
||||
page = await browser.newPage();
|
||||
}
|
||||
|
||||
if (data.browserType === BrowserType.Firefox) {
|
||||
browser = await firefox.launch();
|
||||
browser = await firefox.launch({
|
||||
executablePath: await this.getFirefoxExecutablePath(),
|
||||
});
|
||||
page = await browser.newPage();
|
||||
}
|
||||
|
||||
|
2
Probe/package-lock.json
generated
2
Probe/package-lock.json
generated
@ -16,7 +16,7 @@
|
||||
"ejs": "^3.1.10",
|
||||
"Model": "file:../Model",
|
||||
"ping": "^0.4.4",
|
||||
"playwright": "^1.44.1",
|
||||
"playwright": "latest",
|
||||
"ts-node": "^10.9.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
@ -25,7 +25,7 @@
|
||||
"ejs": "^3.1.10",
|
||||
"Model": "file:../Model",
|
||||
"ping": "^0.4.4",
|
||||
"playwright": "^1.44.1",
|
||||
"playwright": "latest",
|
||||
"ts-node": "^10.9.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
Loading…
Reference in New Issue
Block a user