Skip to content

Commit

Permalink
Copy all environment variables to logstash
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Westergaard Lassen authored and mwl committed Feb 1, 2016
1 parent cb68021 commit ff226c5
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Optional;
import java.util.function.Consumer;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
* Encapsulates a logstash instance. Keeps track of the current container id for logstash.
Expand Down Expand Up @@ -110,10 +112,12 @@ public void run(LogstashProtos.LogstashConfiguration logstashConfiguration) {
"--log", "/var/log/logstash.log",
"-e", serialize(logstashConfiguration)
};
String[] env = {
"LS_HEAP_SIZE=" + System.getProperty("mesos.logstash.logstash.heap.size"),
"HOME=/root"
};

final HashMap<String, String> envs = new HashMap<>(System.getenv());
envs.put("LS_HEAP_SIZE", System.getProperty("mesos.logstash.logstash.heap.size"));
envs.put("HOME", "/root");

String[] env = envs.entrySet().stream().map(kv -> kv.getKey() + "=" + kv.getValue()).toArray(String[]::new);
LOGGER.info("Starting subprocess: " + String.join(" ", env) + " " + String.join(" ", command));
process = Runtime.getRuntime().exec(command, env);
} catch (IOException e) {
Expand Down

0 comments on commit ff226c5

Please sign in to comment.