Enhance server initialization error handling and logging
All checks were successful
farmcontrol/farmcontrol-server/pipeline/head This commit looks good
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:
parent
1525667f54
commit
9a68358432
12
src/index.js
12
src/index.js
@ -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.");
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user