Skip to content

Commit e69f36e

Browse files
committed
Merge remote-tracking branch 'origin/master'
2 parents 63dbb44 + 6136030 commit e69f36e

2 files changed

Lines changed: 16 additions & 4 deletions

File tree

framework/src/main/groovy/org/moqui/impl/context/MessageFacadeImpl.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,9 @@ class MessageFacadeImpl implements MessageFacade {
144144

145145
@Override
146146
void clearAll() {
147+
clearErrors()
147148
if (messageList != null) messageList.clear()
148149
if (publicMessageList != null) publicMessageList.clear()
149-
clearErrors()
150150
}
151151
@Override
152152
void clearErrors() {

framework/src/start/java/MoquiStart.java

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,12 @@ private static Process checkStartElasticSearch() {
562562
}
563563
String javaHome = System.getProperty("java.home");
564564
System.out.println("Starting " + (osDirExists ? "OpenSearch" : "ElasticSearch") + " install found in " + workDir + ", pid file not found (JDK: " + javaHome + ")");
565-
boolean isWindows = System.getProperty("os.name").toLowerCase().startsWith("windows");
565+
566+
String os = System.getProperty("os.name").toLowerCase();
567+
boolean isWindows = os.startsWith("windows");
568+
boolean isMac = os.startsWith("mac");
569+
boolean isLinux = os.contains("nix") || os.contains("nux") || os.contains("aix");
570+
566571
try {
567572
String[] command;
568573
if (isWindows) {
@@ -571,9 +576,16 @@ private static Process checkStartElasticSearch() {
571576
command = new String[]{"./bin/" + baseName};
572577
try {
573578
boolean elasticsearchOwner = Files.getOwner(Paths.get(runtimePath, baseName)).getName().equals(baseName);
574-
boolean suAble = Runtime.getRuntime().exec(new String[]{"/bin/su", "-c", "/bin/true", baseName}).waitFor() == 0;
579+
boolean suAble = false;
580+
if (isLinux) {
581+
suAble = Runtime.getRuntime().exec(new String[]{"/bin/su", "-c", "/bin/true", baseName}).waitFor() == 0;
582+
} else if(isMac) {
583+
suAble = Runtime.getRuntime().exec(new String[]{"/usr/bin/sudo", "-n", "/usr/bin/true"}).waitFor() == 0;
584+
}
575585
if (elasticsearchOwner && suAble) command = new String[]{"su", "-c", "./bin/" + baseName, baseName};
576-
} catch (IOException e) {}
586+
} catch (IOException e) {
587+
System.out.println("Error to run " + (Arrays.toString(new String[]{"/usr/bin/sudo", "-n", "/usr/bin/true"})) + ": " + e.getMessage());
588+
}
577589
}
578590
ProcessBuilder pb = new ProcessBuilder(command);
579591
pb.redirectErrorStream(true);

0 commit comments

Comments
 (0)