@@ -75,6 +75,12 @@ public class Docker {
75
75
public static final int STARTUP_SLEEP_INTERVAL_MILLISECONDS = 1000 ;
76
76
public static final int STARTUP_ATTEMPTS_MAX = 30 ;
77
77
78
+ private static final String ELASTICSEARCH_FULL_CLASSNAME = "org.elasticsearch.bootstrap.Elasticsearch" ;
79
+ private static final String FIND_ELASTICSEARCH_PROCESS = "for pid in $(ps -eo pid,comm | grep java | awk '\\ ''{print $1}'\\ ''); "
80
+ + "do cmdline=$(tr \" \\ 0\" \" \" < /proc/$pid/cmdline 2>/dev/null); [[ $cmdline == *"
81
+ + ELASTICSEARCH_FULL_CLASSNAME + "* ]] && echo \" $pid: $cmdline\" ; done" ;
82
+ // The length of the command exceeds what we can use for COLUMNS so we use a pipe to detect the process we're looking for
83
+
78
84
/**
79
85
* Tracks the currently running Docker image. An earlier implementation used a fixed container name,
80
86
* but that appeared to cause problems with repeatedly destroying and recreating containers with
@@ -185,14 +191,7 @@ public static void waitForElasticsearchToStart() {
185
191
try {
186
192
// Give the container enough time for security auto-configuration or a chance to crash out
187
193
Thread .sleep (STARTUP_SLEEP_INTERVAL_MILLISECONDS );
188
- String detectCommand =
189
- "for pid in $(ps -eo pid,comm | grep java | awk '\\ ''{print $1}'\\ ''); do cmdline=$(tr \" \\ 0\" \" \" < /proc/$pid/cmdline 2>/dev/null); [[ $cmdline == *org.elasticsearch.bootstrap.Elasticsearch* ]] && echo \" PID $pid: $cmdline\" ; done | wc -l" ;
190
- // The length of the command exceeds what we can use for COLUMNS so we use a pipe to detect the process we're looking for
191
- psOutput = dockerShell .run ("bash -c '" + detectCommand + "'" ).stdout ();
192
- // System.out.println("psOutput = " + psOutput);
193
- // psOutput = dockerShell.run(
194
- // "bash -c 'COLUMNS=4000 ps w | grep org.elasticsearch.bootstrap.Elasticsearch | grep -v grep | wc -l'"
195
- // ).stdout();
194
+ psOutput = dockerShell .run ("bash -c '" + FIND_ELASTICSEARCH_PROCESS + " | wc -l'" ).stdout ();
196
195
if (psOutput .contains ("1" )) {
197
196
isElasticsearchRunning = true ;
198
197
break ;
0 commit comments