in src/dataEditor/dataEditorClient.ts [1095:1160]
async function serverStart() {
await serverStop()
const serverStartingText = `Ωedit server starting on port ${omegaEditPort}`
const statusBarItem = vscode.window.createStatusBarItem(
vscode.StatusBarAlignment.Left
)
statusBarItem.text = serverStartingText
statusBarItem.show()
let animationFrame = 0
const animationInterval = 400 // ms per frame
const animationFrames = ['', '.', '..', '...']
const animationIntervalId = setInterval(() => {
const frame = animationFrames[animationFrame % animationFrames.length]
statusBarItem.text = `${serverStartingText} ${frame}`
++animationFrame
}, animationInterval)
const config = vscode.workspace.getConfiguration('dataEditor')
const logLevel =
process.env.OMEGA_EDIT_SERVER_LOG_LEVEL ||
process.env.OMEGA_EDIT_LOG_LEVEL ||
config.get<string>('logLevel', 'info')
const logConfigFile = generateLogbackConfigFile(
path.join(APP_DATA_PATH, `serv-${omegaEditPort}.log`),
logLevel
)
if (!fs.existsSync(logConfigFile)) {
throw new Error(`Log config file '${logConfigFile}' not found`)
}
// Start the server and wait up to 10 seconds for it to start
const serverPid = (await Promise.race([
startServer(
omegaEditPort,
OMEGA_EDIT_HOST,
getPidFile(omegaEditPort),
logConfigFile
),
new Promise((resolve, reject) => {
setTimeout(() => {
reject((): Error => {
return new Error(
`Server startup timed out after ${SERVER_START_TIMEOUT} seconds`
)
})
}, SERVER_START_TIMEOUT * 1000)
}),
])) as number | undefined
if (serverPid === undefined || serverPid <= 0) {
throw new Error('Server failed to start or PID is invalid')
}
const clientVersion = getClientVersion()
const serverVersion = await getServerVersion()
if (serverVersion !== clientVersion) {
throw new Error(
`Server version ${serverVersion} and client version ${clientVersion} must match`
)
}
// get an initial heartbeat to ensure the server is up and running
await getHeartbeat()
clearInterval(animationIntervalId)
statusBarItem.text = `Ωedit server v${serverVersion} started on port ${omegaEditPort} with PID ${serverPid}`
setTimeout(() => {
statusBarItem.dispose()
}, 5000)
}