temp: rewrite headless config
This commit is contained in:
@@ -464,13 +464,7 @@ async function createWorkflowAndStoreMetadata(id: string, userId: string) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const browserId = createRemoteBrowserForRun({
|
const browserId = createRemoteBrowserForRun(userId);
|
||||||
browser: chromium,
|
|
||||||
launchOptions: {
|
|
||||||
headless: true,
|
|
||||||
proxy: proxyOptions.server ? proxyOptions : undefined,
|
|
||||||
}
|
|
||||||
}, userId);
|
|
||||||
|
|
||||||
const runId = uuid();
|
const runId = uuid();
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import {
|
|||||||
Browser,
|
Browser,
|
||||||
CDPSession,
|
CDPSession,
|
||||||
BrowserContext,
|
BrowserContext,
|
||||||
|
chromium,
|
||||||
} from 'playwright';
|
} from 'playwright';
|
||||||
import { Socket } from "socket.io";
|
import { Socket } from "socket.io";
|
||||||
import { PlaywrightBlocker } from '@cliqz/adblocker-playwright';
|
import { PlaywrightBlocker } from '@cliqz/adblocker-playwright';
|
||||||
@@ -91,35 +92,39 @@ export class RemoteBrowser {
|
|||||||
* @param options remote browser options to be used when launching the browser
|
* @param options remote browser options to be used when launching the browser
|
||||||
* @returns {Promise<void>}
|
* @returns {Promise<void>}
|
||||||
*/
|
*/
|
||||||
public initialize = async (options: RemoteBrowserOptions, userId: string): Promise<void> => {
|
public initialize = async (userId: string): Promise<void> => {
|
||||||
const launchOptions = {
|
// const launchOptions = {
|
||||||
|
// headless: true,
|
||||||
|
// proxy: options.launchOptions?.proxy,
|
||||||
|
// chromiumSandbox: false,
|
||||||
|
// args: [
|
||||||
|
// '--no-sandbox',
|
||||||
|
// '--disable-setuid-sandbox',
|
||||||
|
// '--headless=new',
|
||||||
|
// '--disable-gpu',
|
||||||
|
// '--disable-dev-shm-usage',
|
||||||
|
// '--disable-software-rasterizer',
|
||||||
|
// '--in-process-gpu',
|
||||||
|
// '--disable-infobars',
|
||||||
|
// '--single-process',
|
||||||
|
// '--no-zygote',
|
||||||
|
// '--disable-notifications',
|
||||||
|
// '--disable-extensions',
|
||||||
|
// '--disable-background-timer-throttling',
|
||||||
|
// ...(options.launchOptions?.args || [])
|
||||||
|
// ],
|
||||||
|
// env: {
|
||||||
|
// ...process.env,
|
||||||
|
// CHROMIUM_FLAGS: '--disable-gpu --no-sandbox --headless=new'
|
||||||
|
// }
|
||||||
|
// };
|
||||||
|
// console.log('Launch options before:', options.launchOptions);
|
||||||
|
// this.browser = <Browser>(await options.browser.launch(launchOptions));
|
||||||
|
|
||||||
|
// console.log('Launch options after:', options.launchOptions)
|
||||||
|
this.browser = <Browser>(await chromium.launch({
|
||||||
headless: true,
|
headless: true,
|
||||||
proxy: options.launchOptions?.proxy,
|
}));
|
||||||
chromiumSandbox: false,
|
|
||||||
args: [
|
|
||||||
'--no-sandbox',
|
|
||||||
'--disable-setuid-sandbox',
|
|
||||||
'--headless=new',
|
|
||||||
'--disable-gpu',
|
|
||||||
'--disable-dev-shm-usage',
|
|
||||||
'--disable-software-rasterizer',
|
|
||||||
'--in-process-gpu',
|
|
||||||
'--disable-infobars',
|
|
||||||
'--single-process',
|
|
||||||
'--no-zygote',
|
|
||||||
'--disable-notifications',
|
|
||||||
'--disable-extensions',
|
|
||||||
'--disable-background-timer-throttling',
|
|
||||||
...(options.launchOptions?.args || [])
|
|
||||||
],
|
|
||||||
env: {
|
|
||||||
...process.env,
|
|
||||||
CHROMIUM_FLAGS: '--disable-gpu --no-sandbox --headless=new'
|
|
||||||
}
|
|
||||||
};
|
|
||||||
console.log('Launch options before:', options.launchOptions);
|
|
||||||
this.browser = <Browser>(await options.browser.launch(launchOptions));
|
|
||||||
console.log('Launch options after:', options.launchOptions)
|
|
||||||
const proxyConfig = await getDecryptedProxyConfig(userId);
|
const proxyConfig = await getDecryptedProxyConfig(userId);
|
||||||
let proxyOptions: { server: string, username?: string, password?: string } = { server: '' };
|
let proxyOptions: { server: string, username?: string, password?: string } = { server: '' };
|
||||||
if (proxyConfig.proxy_url) {
|
if (proxyConfig.proxy_url) {
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import logger from "../logger";
|
|||||||
* @returns string
|
* @returns string
|
||||||
* @category BrowserManagement-Controller
|
* @category BrowserManagement-Controller
|
||||||
*/
|
*/
|
||||||
export const initializeRemoteBrowserForRecording = (options: RemoteBrowserOptions, userId: string): string => {
|
export const initializeRemoteBrowserForRecording = (userId: string): string => {
|
||||||
const id = getActiveBrowserId() || uuid();
|
const id = getActiveBrowserId() || uuid();
|
||||||
createSocketConnection(
|
createSocketConnection(
|
||||||
io.of(id),
|
io.of(id),
|
||||||
@@ -34,8 +34,7 @@ export const initializeRemoteBrowserForRecording = (options: RemoteBrowserOption
|
|||||||
} else {
|
} else {
|
||||||
const browserSession = new RemoteBrowser(socket);
|
const browserSession = new RemoteBrowser(socket);
|
||||||
browserSession.interpreter.subscribeToPausing();
|
browserSession.interpreter.subscribeToPausing();
|
||||||
console.log(`Initialized Browser Config: ${JSON.stringify(options)}`);
|
await browserSession.initialize(userId);
|
||||||
await browserSession.initialize(options, userId);
|
|
||||||
await browserSession.registerEditorEvents();
|
await browserSession.registerEditorEvents();
|
||||||
await browserSession.subscribeToScreencast();
|
await browserSession.subscribeToScreencast();
|
||||||
browserPool.addRemoteBrowser(id, browserSession, true);
|
browserPool.addRemoteBrowser(id, browserSession, true);
|
||||||
@@ -53,13 +52,13 @@ export const initializeRemoteBrowserForRecording = (options: RemoteBrowserOption
|
|||||||
* @returns string
|
* @returns string
|
||||||
* @category BrowserManagement-Controller
|
* @category BrowserManagement-Controller
|
||||||
*/
|
*/
|
||||||
export const createRemoteBrowserForRun = (options: RemoteBrowserOptions, userId: string): string => {
|
export const createRemoteBrowserForRun = (userId: string): string => {
|
||||||
const id = uuid();
|
const id = uuid();
|
||||||
createSocketConnectionForRun(
|
createSocketConnectionForRun(
|
||||||
io.of(id),
|
io.of(id),
|
||||||
async (socket: Socket) => {
|
async (socket: Socket) => {
|
||||||
const browserSession = new RemoteBrowser(socket);
|
const browserSession = new RemoteBrowser(socket);
|
||||||
await browserSession.initialize(options, userId);
|
await browserSession.initialize(userId);
|
||||||
browserPool.addRemoteBrowser(id, browserSession, true);
|
browserPool.addRemoteBrowser(id, browserSession, true);
|
||||||
socket.emit('ready-for-run');
|
socket.emit('ready-for-run');
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -56,13 +56,7 @@ router.get('/start', requireSignIn, async (req: AuthenticatedRequest, res: Respo
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const id = initializeRemoteBrowserForRecording({
|
const id = initializeRemoteBrowserForRecording(req.user.id);
|
||||||
browser: chromium,
|
|
||||||
launchOptions: {
|
|
||||||
headless: true,
|
|
||||||
proxy: proxyOptions.server ? proxyOptions : undefined,
|
|
||||||
}
|
|
||||||
}, req.user.id);
|
|
||||||
console.log('id start:', id);
|
console.log('id start:', id);
|
||||||
return res.send(id);
|
return res.send(id);
|
||||||
});
|
});
|
||||||
@@ -75,13 +69,7 @@ router.post('/start', requireSignIn, (req: AuthenticatedRequest, res:Response) =
|
|||||||
if (!req.user) {
|
if (!req.user) {
|
||||||
return res.status(401).send('User not authenticated');
|
return res.status(401).send('User not authenticated');
|
||||||
}
|
}
|
||||||
const id = initializeRemoteBrowserForRecording({
|
const id = initializeRemoteBrowserForRecording(req.user.id);
|
||||||
browser: chromium,
|
|
||||||
launchOptions: {
|
|
||||||
headless: true,
|
|
||||||
...req.body,
|
|
||||||
}
|
|
||||||
}, req.user.id);
|
|
||||||
console.log('id start POST:', id);
|
console.log('id start POST:', id);
|
||||||
return res.send(id);
|
return res.send(id);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -158,13 +158,7 @@ router.put('/runs/:id', requireSignIn, async (req: AuthenticatedRequest, res) =>
|
|||||||
|
|
||||||
console.log(`Proxy config for run: ${JSON.stringify(proxyOptions)}`)
|
console.log(`Proxy config for run: ${JSON.stringify(proxyOptions)}`)
|
||||||
|
|
||||||
const id = createRemoteBrowserForRun({
|
const id = createRemoteBrowserForRun(req.user.id);
|
||||||
browser: chromium,
|
|
||||||
launchOptions: {
|
|
||||||
headless: true,
|
|
||||||
proxy: proxyOptions.server ? proxyOptions : undefined,
|
|
||||||
}
|
|
||||||
}, req.user.id);
|
|
||||||
|
|
||||||
const runId = uuid();
|
const runId = uuid();
|
||||||
|
|
||||||
|
|||||||
@@ -40,13 +40,7 @@ async function createWorkflowAndStoreMetadata(id: string, userId: string) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const browserId = createRemoteBrowserForRun({
|
const browserId = createRemoteBrowserForRun( userId);
|
||||||
browser: chromium,
|
|
||||||
launchOptions: {
|
|
||||||
headless: true,
|
|
||||||
proxy: proxyOptions.server ? proxyOptions : undefined,
|
|
||||||
}
|
|
||||||
}, userId);
|
|
||||||
const runId = uuid();
|
const runId = uuid();
|
||||||
|
|
||||||
const run = await Run.create({
|
const run = await Run.create({
|
||||||
|
|||||||
Reference in New Issue
Block a user