From 58b30144f2d5c0f2983a58640d7d77c2b60b9dca Mon Sep 17 00:00:00 2001 From: Jordi Deu-Pons Date: Wed, 15 Dec 2021 16:11:58 +0100 Subject: [PATCH] On error, use always exit code 1 instead of -1 --- src/main/java/io/seqera/tower/agent/Agent.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main/java/io/seqera/tower/agent/Agent.java b/src/main/java/io/seqera/tower/agent/Agent.java index 0d4f19b..bc3b051 100644 --- a/src/main/java/io/seqera/tower/agent/Agent.java +++ b/src/main/java/io/seqera/tower/agent/Agent.java @@ -100,7 +100,7 @@ public void run() { sendPeriodicHeartbeat(); } catch (Exception e) { logger.error(e.getMessage()); - System.exit(-1); + System.exit(1); } } @@ -112,7 +112,7 @@ private void connectTower() { final URI uri = new URI(url + "/agent/" + agentKey + "/connect"); if (!uri.getScheme().equals("https")) { logger.error("You are trying to connect to an insecure server: {}", url); - System.exit(-1); + System.exit(1); } final MutableHttpRequest req = HttpRequest.GET(uri).bearerAuth(token); @@ -165,7 +165,7 @@ private void execCommand(CommandRequest message) { agentClient.send(response); } catch (Exception e) { // send result - CommandResponse response = new CommandResponse(message.getId(), e.getMessage().getBytes(), -1); + CommandResponse response = new CommandResponse(message.getId(), e.getMessage().getBytes(), 1); agentClient.send(response); } } @@ -200,7 +200,7 @@ private void validateParameters() throws IOException { validatedUserName = System.getProperty("user.name"); if (validatedUserName == null || validatedUserName.isEmpty() || validatedUserName.isBlank()) { logger.error("Impossible to detect current Unix username."); - System.exit(-1); + System.exit(1); } // Set default workDir @@ -210,14 +210,14 @@ private void validateParameters() throws IOException { workDir = Paths.get(defaultPath); } catch (InvalidPathException e) { logger.error("Impossible to define a default work directory. Please provide one using '--work-dir'."); - System.exit(-1); + System.exit(1); } } // Validate workDir exists if (!Files.exists(workDir)) { logger.error("The work directory '{}' do not exists. Create it or provide a different one using '--work-dir'.", workDir); - System.exit(-1); + System.exit(1); } validatedWorkDir = workDir.toAbsolutePath().normalize().toString(); @@ -246,7 +246,7 @@ private void checkTower() { if (systemApiVersion.compareTo(requiredApiVersion) < 0) { logger.error("Tower at '{}' is running API version {} and the agent needs a minimum of {}", url, systemApiVersion, requiredApiVersion); - System.exit(-1); + System.exit(1); } } } catch (Exception e) { @@ -255,7 +255,7 @@ private void checkTower() { } else { logger.error("Tower API endpoint '{}' it is not available (did you mean '{}/api'?)", url, url); } - System.exit(-1); + System.exit(1); } try { @@ -264,7 +264,7 @@ private void checkTower() { httpClient.retrieve(req).blockingFirst(); } catch (Exception e) { logger.error("Invalid TOWER_ACCESS_TOKEN, check that the given token has access at '{}'.", url); - System.exit(-1); + System.exit(1); } }