Do the root check first, so resource limits arent confusing if you are root.

This commit is contained in:
Robert Muir 2015-05-30 11:20:20 -04:00
parent 74bb715689
commit 1e5e36d48d
1 changed files with 9 additions and 8 deletions

View File

@ -84,14 +84,6 @@ public class Bootstrap {
/** initialize native resources */
public static void initializeNatives(boolean mlockAll, boolean ctrlHandler, boolean loadSigar) {
final ESLogger logger = Loggers.getLogger(Bootstrap.class);
// mlockall if requested
if (mlockAll) {
if (Constants.WINDOWS) {
Natives.tryVirtualLock();
} else {
Natives.tryMlockall();
}
}
// check if the user is running as root, and bail
if (Natives.definitelyRunningAsRoot()) {
@ -101,6 +93,15 @@ public class Bootstrap {
throw new RuntimeException("don't run elasticsearch as root.");
}
}
// mlockall if requested
if (mlockAll) {
if (Constants.WINDOWS) {
Natives.tryVirtualLock();
} else {
Natives.tryMlockall();
}
}
// listener for windows close event
if (ctrlHandler) {