adopt --server-data-dir

pull/141172/head
Martin Aeschlimann 2022-01-21 12:11:47 +01:00
parent 8047f9c877
commit f9cac7c28a
No known key found for this signature in database
GPG Key ID: 2609A01E695523E3
6 changed files with 20 additions and 26 deletions

View File

@ -85,14 +85,14 @@ export function activate(context: vscode.ExtensionContext) {
const { updateUrl, commit, quality, serverDataFolderName, serverApplicationName, dataFolderName } = getProductConfiguration();
const commandArgs = ['--host=127.0.0.1', '--port=0', '--disable-telemetry', '--use-host-proxy', '--accept-server-license-terms'];
const env = getNewEnv();
const remoteDataDir = process.env['TESTRESOLVER_DATA_FOLDER'] || path.join(os.homedir(), serverDataFolderName || `${dataFolderName}-testresolver`);
const remoteDataDir = process.env['TESTRESOLVER_DATA_FOLDER'] || path.join(os.homedir(), `${serverDataFolderName || dataFolderName}-testresolver`);
const logsDir = process.env['TESTRESOLVER_LOGS_FOLDER'];
if (logsDir) {
commandArgs.push('--logsPath', logsDir);
}
env['VSCODE_AGENT_FOLDER'] = remoteDataDir;
outputChannel.appendLine(`Using data folder at ${remoteDataDir}`);
commandArgs.push('--server-data-dir', remoteDataDir);
const connectionTokenFile = path.join(remoteDataDir, `${process.pid}-${new Date().getTime()}.token`);
if (!fs.existsSync(remoteDataDir)) {
@ -106,7 +106,7 @@ export function activate(context: vscode.ExtensionContext) {
const vscodePath = path.resolve(path.join(context.extensionPath, '..', '..'));
const serverCommandPath = path.join(vscodePath, 'scripts', serverCommand);
outputChannel.appendLine(`Launching server: VSCODE_AGENT_FOLDER="${remoteDataDir}" "${serverCommandPath}" ${commandArgs.join(' ')}`);
outputChannel.appendLine(`Launching server: "${serverCommandPath}" ${commandArgs.join(' ')}`);
extHostProcess = cp.spawn(serverCommandPath, commandArgs, { env, cwd: vscodePath });
} else {

View File

@ -10,6 +10,7 @@
"serverLicense": [],
"serverLicensePrompt": "",
"serverApplicationName": "code-server-oss",
"serverDataFolderName": ".vscode-server-oss",
"win32DirName": "Microsoft Code OSS",
"win32NameVersion": "Microsoft Code OSS",
"win32RegValueName": "CodeOSS",

View File

@ -21,7 +21,8 @@ const args = minimist(process.argv.slice(2), {
'host',
'port',
'driver',
'connection-token'
'connection-token',
'server-data-dir'
],
});
@ -38,7 +39,7 @@ const HOST = args['host'] ?? 'localhost';
const PORT = args['port'] ?? '9888';
const TOKEN = args['connection-token'] ?? String(crypto.randomInt(0xffffffff));
if (args['connection-token'] === undefined && args['connection-token-file'] === undefined && !args['no-connection-token']) {
if (args['launch'] && args['connection-token'] === undefined && args['connection-token-file'] === undefined && !args['no-connection-token']) {
serverArgs.push('--connection-token', TOKEN);
}
if (args['host'] === undefined) {
@ -48,13 +49,7 @@ if (args['port'] === undefined) {
serverArgs.push('--port', PORT);
}
if (args['driver']) {
// given a DRIVER, we auto-shutdown when tests are done
serverArgs.push('--enable-remote-auto-shutdown', '--remote-auto-shutdown-without-delay');
}
const env = { ...process.env };
env['VSCODE_AGENT_FOLDER'] = env['VSCODE_AGENT_FOLDER'] || path.join(os.homedir(), '.vscode-server-oss-dev');
env['NODE_ENV'] = 'development';
env['VSCODE_DEV'] = '1';
const entryPoint = path.join(__dirname, '..', '..', '..', 'out', 'server-main.js');
@ -75,7 +70,7 @@ function startServer() {
console.error(data.toString());
});
proc.on('exit', () => process.exit());
proc.on('exit', (code) => process.exit(code));
process.on('exit', () => proc.kill());
process.on('SIGINT', () => {

View File

@ -39,7 +39,8 @@ else if (typeof require?.__$__nodeRequire === 'function') {
Object.assign(product, {
nameShort: `${product.nameShort} Dev`,
nameLong: `${product.nameLong} Dev`,
dataFolderName: `${product.dataFolderName}-dev`
dataFolderName: `${product.dataFolderName}-dev`,
serverDataFolderName: product.serverDataFolderName ? `${product.serverDataFolderName}-dev` : undefined
});
}

View File

@ -220,29 +220,28 @@ async function launchServer(options: LaunchOptions) {
const agentFolder = userDataDir;
await measureAndLog(promisify(mkdir)(agentFolder), `mkdir(${agentFolder})`, logger);
const env = {
VSCODE_AGENT_FOLDER: agentFolder,
VSCODE_REMOTE_SERVER_PATH: codeServerPath,
...process.env
};
const args = ['--disable-telemetry', '--port', `${port++}`, '--browser', 'none', '--driver', 'web', '--extensions-dir', extensionsPath];
const args = ['--disable-telemetry', '--port', `${port++}`, '--driver', 'web', '--extensions-dir', extensionsPath, '--server-data-dir', agentFolder];
let serverLocation: string | undefined;
if (codeServerPath) {
const { serverApplicationName } = require(join(codeServerPath, 'product.json'));
serverLocation = join(codeServerPath, 'bin', `${serverApplicationName}${process.platform === 'win32' ? '.cmd' : ''}`);
args.push(`--logsPath=${logsPath}`);
logger.log(`Starting built server from '${serverLocation}'`);
logger.log(`Storing log files into '${logsPath}'`);
} else {
serverLocation = join(root, `scripts/code-server.${process.platform === 'win32' ? 'bat' : 'sh'}`);
args.push('--logsPath', logsPath);
logger.log(`Starting server out of sources from '${serverLocation}'`);
logger.log(`Storing log files into '${logsPath}'`);
}
logger.log(`Storing log files into '${logsPath}'`);
args.push('--logsPath', logsPath);
logger.log(`Command line: '${serverLocation}' ${args.join(' ')}`);
const serverProcess = spawn(
serverLocation,
args,
@ -315,7 +314,7 @@ async function teardown(server: ChildProcess, logger: Logger): Promise<void> {
}
function waitForEndpoint(server: ChildProcess): Promise<string> {
return new Promise<string>(resolve => {
return new Promise<string>((resolve, reject) => {
server.stdout?.on('data', (d: Buffer) => {
const matches = d.toString('ascii').match(/Web UI available at (.+)/);
if (matches !== null) {

View File

@ -118,7 +118,6 @@ async function launchServer(browserType: BrowserType): Promise<{ endpoint: url.U
const userDataDir = path.join(testDataPath, 'd');
const env = {
VSCODE_AGENT_FOLDER: userDataDir,
VSCODE_BROWSER: browserType,
...process.env
};
@ -126,29 +125,28 @@ async function launchServer(browserType: BrowserType): Promise<{ endpoint: url.U
const root = path.join(__dirname, '..', '..', '..', '..');
const logsPath = path.join(root, '.build', 'logs', 'integration-tests-browser');
const serverArgs = ['--browser', 'none', '--driver', 'web', '--enable-proposed-api', '--disable-telemetry'];
const serverArgs = ['--driver', 'web', '--enable-proposed-api', '--disable-telemetry', '--server-data-dir', userDataDir];
let serverLocation: string;
if (process.env.VSCODE_REMOTE_SERVER_PATH) {
const { serverApplicationName } = require(path.join(process.env.VSCODE_REMOTE_SERVER_PATH, 'product.json'));
serverLocation = path.join(process.env.VSCODE_REMOTE_SERVER_PATH, 'bin', `${serverApplicationName}${process.platform === 'win32' ? '.cmd' : ''}`);
serverArgs.push(`--logsPath=${logsPath}`);
if (optimist.argv.debug) {
console.log(`Starting built server from '${serverLocation}'`);
console.log(`Storing log files into '${logsPath}'`);
}
} else {
serverLocation = path.join(root, `scripts/code-server.${process.platform === 'win32' ? 'bat' : 'sh'}`);
serverArgs.push('--logsPath', logsPath);
process.env.VSCODE_DEV = '1';
if (optimist.argv.debug) {
console.log(`Starting server out of sources from '${serverLocation}'`);
console.log(`Storing log files into '${logsPath}'`);
}
}
console.log(`Storing log files into '${logsPath}'`);
serverArgs.push('--logsPath', logsPath);
const stdio: cp.StdioOptions = optimist.argv.debug ? 'pipe' : ['ignore', 'pipe', 'ignore'];
let serverProcess = cp.spawn(