You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by jb...@apache.org on 2019/11/01 12:14:48 UTC
[karaf] branch master updated: [KARAF-6428] Consistency in
bin/status to return running or not running only
This is an automated email from the ASF dual-hosted git repository.
jbonofre pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/karaf.git
The following commit(s) were added to refs/heads/master by this push:
new 165b791 [KARAF-6428] Consistency in bin/status to return running or not running only
new 765ce6b Merge pull request #985 from jbonofre/KARAF-6428
165b791 is described below
commit 165b79174c96ff6f793741617494c8b80c759af2
Author: Jean-Baptiste Onofré <jb...@apache.org>
AuthorDate: Fri Nov 1 07:38:23 2019 +0100
[KARAF-6428] Consistency in bin/status to return running or not running only
---
main/src/main/java/org/apache/karaf/main/Status.java | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/main/src/main/java/org/apache/karaf/main/Status.java b/main/src/main/java/org/apache/karaf/main/Status.java
index ff7e042..58d02f1 100644
--- a/main/src/main/java/org/apache/karaf/main/Status.java
+++ b/main/src/main/java/org/apache/karaf/main/Status.java
@@ -29,6 +29,9 @@ import java.net.Socket;
*/
public class Status {
+ private final static String RUNNING = "Running ...";
+ private final static String NOT_RUNNING = "Not Running ...";
+
/**
* Checks if the shutdown port is bound. The shutdown port can be configured in config.properties
* or in the shutdown port file.
@@ -42,24 +45,26 @@ public class Status {
try {
config.shutdownPort = getPortFromShutdownPortFile(config.portFile);
} catch (FileNotFoundException fnfe) {
- System.err.println(config.portFile + " shutdown port file doesn't exist. The container is not running.");
+ System.out.println(NOT_RUNNING);
+ // cause with exit code 3: shutdown port file doesn't exist. The container is not running.
System.exit(3);
} catch (IOException ioe) {
- System.err.println("Can't read " + config.portFile + " port file: " + ioe.getMessage());
+ System.out.println(NOT_RUNNING);
+ // cause with exit code 4: can't read port file
System.exit(4);
}
}
if (config.shutdownPort > 0) {
try (Socket s = new Socket(config.shutdownHost, config.shutdownPort)) {
if (s.isBound()) {
- System.out.println("Running ...");
+ System.out.println(RUNNING);
System.exit(0);
} else {
- System.out.println("Not Running ...");
+ System.out.println(NOT_RUNNING);
System.exit(1);
}
} catch (ConnectException connectException) {
- System.out.println("Not Running ...");
+ System.out.println(NOT_RUNNING);
System.exit(1);
}
} else {
@@ -67,10 +72,10 @@ public class Status {
int pid = getPidFromPidFile(config.pidFile);
org.apache.karaf.jpm.Process process = new ProcessBuilderFactoryImpl().newBuilder().attach(pid);
if (process.isRunning()) {
- System.out.println("Running ... (pid " + pid + ")");
+ System.out.println(RUNNING + " (pid " + pid + ")");
System.exit(0);
} else {
- System.out.println("Not Running ...");
+ System.out.println(NOT_RUNNING);
System.exit(1);
}
}