diff --git a/install.ts b/install.ts index 97758d5..0dae6ab 100644 --- a/install.ts +++ b/install.ts @@ -30,9 +30,10 @@ export async function install(engine: SandboxEngine) { entry.engine === engine && entry.arch === arch && entry.type === type )?.url if (!url) { - throw new Error( + console.warn( `No ${engine} binary is available for your OS type (${type}) and architecture (${arch}).` ) + return } const archiveFilename = posix diff --git a/run.ts b/run.ts index df3ac81..ebc547f 100644 --- a/run.ts +++ b/run.ts @@ -57,18 +57,42 @@ export class LocalSearch { const logsDir = join(tempDir, 'logs') await Promise.all([dataDir, logsDir].map(mkdirP)) - const args: string[] = [ - `-Epath.data=${dataDir}`, - `-Epath.logs=${logsDir}`, - `-Ehttp.port=${port}`, - '-Ediscovery.type=single-node', + let command + let args = [] + const opts = [ + `http.port=${port}`, + 'discovery.type=single-node', engine === 'elasticsearch' - ? '-Expack.security.enabled=false' - : '-Eplugins.security.disabled=true', + ? 'xpack.security.enabled=false' + : 'plugins.security.disabled=true', ] - console.log('Spawning', bin, ...args) - child = await spawn(bin, args, { + if (bin) { + command = bin + opts.push(`path.data=${dataDir}`, `path.logs=${logsDir}`) + args = opts.map((opt) => `-E${opt}`) + } else { + command = 'docker' + opts.push('path.data=/docker.data', 'path.logs=/docker.logs') + args = [ + 'run', + '--rm', + '-i', + '-p', + `${port}:${port}`, + '-v', + `${dataDir}:/docker.data`, + '-v', + `${logsDir}:/docker.logs`, + ...opts.flatMap((opt) => ['-e', opt]), + engine === 'elasticsearch' + ? 'elastic/elasticsearch:8.6.2' + : 'opensearchproject/opensearch:2.11.0', + ] + } + + console.log('Spawning', command, ...args) + child = await spawn(command, args, { stdio: ['ignore', 'ignore', 'inherit'], })