Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (error.code !== 'ENOENT') {
storeServerLogger.error(error, `Got error unlinking server.json, but the process is already exiting`)
}
}
})
const store = await createNewStoreController(Object.assign(opts, {
storeDir,
}))
const protocol = opts.protocol ?? (opts.port ? 'tcp' : 'auto')
const serverOptions = await getServerOptions(connectionInfoDir, { protocol, port: opts.port })
const connectionOptions = {
remotePrefix: serverOptions.path
? `http://unix:${serverOptions.path}:`
: `http://${serverOptions.hostname}:${serverOptions.port}`,
}
server = createServer(store.ctrl, {
...serverOptions,
ignoreStopRequests: opts.ignoreStopRequests,
ignoreUploadRequests: opts.ignoreUploadRequests,
})
// Make sure to populate server.json after the server has started, so clients know that the server is
// listening if a server.json with valid JSON content exists.
const serverJson = {
connectionOptions,
pid: process.pid,
pnpmVersion: packageManager.version,
}
const serverJsonStr = JSON.stringify(serverJson, undefined, 2) // undefined and 2 are for formatting.
const serverJsonBuffer = Buffer.from(serverJsonStr, 'utf8')
// fs.write on NodeJS 4 requires the parameters offset and length to be set:
// https://nodejs.org/docs/latest-v4.x/api/fs.html#fs_fs_write_fd_buffer_offset_length_position_callback
await fs.write(fd, serverJsonBuffer, 0, serverJsonBuffer.byteLength)
if (error.code !== 'ENOENT') {
storeLogger.error(error, `Got error unlinking server.json, but the process is already exiting`)
}
}
})
const store = await createStore(Object.assign(opts, {
store: pathOfStore,
}))
const protocol = opts.protocol || opts.port && 'tcp' || 'auto'
const serverOptions = await getServerOptions(connectionInfoDir, { protocol, port: opts.port })
const connectionOptions = {
remotePrefix: serverOptions.path
? `http://unix:${serverOptions.path}:`
: `http://${serverOptions.hostname}:${serverOptions.port}`,
}
server = createServer(store.ctrl, {
...serverOptions,
ignoreStopRequests: opts.ignoreStopRequests,
ignoreUploadRequests: opts.ignoreUploadRequests,
})
// Make sure to populate server.json after the server has started, so clients know that the server is
// listening if a server.json with valid JSON content exists.
const serverJson = {
connectionOptions,
pid: process.pid,
pnpmVersion: packageManager.version,
}
const serverJsonStr = JSON.stringify(serverJson, undefined, 2) // undefined and 2 are for formatting.
const serverJsonBuffer = Buffer.from(serverJsonStr, 'utf8')
// fs.write on NodeJS 4 requires the parameters offset and length to be set:
// https://nodejs.org/docs/latest-v4.x/api/fs.html#fs_fs_write_fd_buffer_offset_length_position_callback
await fs.write(fd, serverJsonBuffer, 0, serverJsonBuffer.byteLength)
metaCache: new Map(),
})
const fetchers = createFetcher({
alwaysAuth: true,
registry,
strictSsl: true,
rawConfig,
})
const storeCtrl = await createStore(resolve, fetchers, {
networkConcurrency: 1,
store,
})
const port = 5813
const hostname = '127.0.0.1';
const server = createServer(storeCtrl, {
port,
hostname,
})
process.on('exit', () => server.close())
}