Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (fd !== null) {
try {
fs.closeSync(fd)
} catch (error) {
storeServerLogger.error(error, `Got error while closing file descriptor of server.json, but the process is already exiting`)
}
}
try {
fs.unlinkSync(serverJsonPath)
} catch (error) {
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.