chore: send run_id from agent to server (#13542)

This commit is contained in:
Yury Semikhatsky 2022-04-13 12:13:35 -07:00 committed by GitHub
parent 00199b5617
commit e2fff31848
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 2 deletions

View File

@ -252,8 +252,9 @@ program
.command('experimental-grid-agent', { hidden: true })
.requiredOption('--agent-id <agentId>', 'agent ID')
.requiredOption('--grid-url <gridURL>', 'grid URL')
.option('--run-id <github run_id>', 'Workflow run_id')
.action(function(options) {
launchGridAgent(options.agentId, options.gridUrl);
launchGridAgent(options.agentId, options.gridUrl, options.runId);
});
program

View File

@ -19,12 +19,14 @@ import WebSocket from 'ws';
import { fork } from 'child_process';
import { getPlaywrightVersion } from '../common/userAgent';
export function launchGridAgent(agentId: string, gridURL: string) {
export function launchGridAgent(agentId: string, gridURL: string, runId: string | undefined) {
const log = debug(`pw:grid:agent:${agentId}`);
log('created');
const params = new URLSearchParams();
params.set('pwVersion', getPlaywrightVersion(true /* majorMinorOnly */));
params.set('agentId', agentId);
if (runId)
params.set('runId', runId);
const ws = new WebSocket(gridURL.replace('http://', 'ws://') + `/registerAgent?` + params.toString());
ws.on('message', (message: string) => {
log('worker requested ' + message);