Enhance server initialization error handling and logging
All checks were successful
farmcontrol/farmcontrol-server/pipeline/head This commit looks good

- Introduce a check for the Farm Control Server status during initialization, providing clearer feedback when the server is not running.
- Improve error handling by logging specific failure messages instead of throwing errors, enhancing user experience during startup.
This commit is contained in:
Tom Butcher 2026-07-27 02:17:34 +01:00
parent 1525667f54
commit 9a68358432

View File

@ -34,16 +34,24 @@ export async function init(options = {}) {
const headless = options.headless ?? isHeadless;
cli.blank();
startWaiting("Checking if Farm Control Server is running...", logger);
const isCommandLines = otpCode != undefined || isInfo == true;
let runningServer;
try {
runningServer = await checkRunning();
await stopWaiting();
if (runningServer == false && isCommandLines == true) {
cli.failure("Farm Control Server is not running.");
cli.blank();
return false;
}
} catch (err) {
await stopWaiting();
throw err;
cli.failure("Failed to check if Farm Control Server is running:", err);
cli.blank();
return false;
}
if (otpCode != undefined || isInfo == true) {
if (isCommandLines == true) {
cli.success("Farm Control Server is running.");
}