use of ai.grakn.bootup.graknengine.Grakn in project grakn by graknlabs.
the class EngineProcess method getClassPathFrom.
protected String getClassPathFrom(Path home) {
FilenameFilter jarFiles = (dir, name) -> name.toLowerCase().endsWith(".jar");
// services/lib folder
File folder = new File(home + File.separator + "services" + File.separator + "lib");
File[] values = folder.listFiles(jarFiles);
if (values == null) {
throw new RuntimeException("No libraries found: cannot run " + COMPONENT_NAME);
}
Stream<File> jars = Stream.of(values);
// /conf
File conf = new File(home + File.separator + "conf" + File.separator);
// services/grakn/server lib
File graknLogback = new File(home + File.separator + "services" + File.separator + "grakn" + File.separator + "server" + File.separator);
return ":" + Stream.concat(jars, Stream.of(conf, graknLogback)).filter(f -> !f.getName().contains("slf4j-log4j12")).map(File::getAbsolutePath).sorted().collect(Collectors.joining(":"));
}
use of ai.grakn.bootup.graknengine.Grakn in project grakn by graknlabs.
the class DistributionContext method getClassPath.
/**
* Get the class path of all the jars in the /lib folder
*/
private String getClassPath() {
Path servicesLibDir = Paths.get(EXTRACTED_DISTRIBUTION_DIRECTORY.toString(), "services", "lib");
Path confDir = Paths.get(EXTRACTED_DISTRIBUTION_DIRECTORY.toString(), "conf");
Path graknLogback = Paths.get(EXTRACTED_DISTRIBUTION_DIRECTORY.toString(), "services", "grakn", "server");
FilenameFilter jarFiles = (dir, name) -> name.toLowerCase().endsWith(".jar");
Stream<File> jars = Stream.of(servicesLibDir.toFile().listFiles(jarFiles));
return Stream.concat(jars, Stream.of(confDir.toFile(), graknLogback.toFile())).filter(f -> !f.getName().contains("slf4j-log4j12")).map(File::getAbsolutePath).collect(joining(":"));
}
use of ai.grakn.bootup.graknengine.Grakn in project grakn by graknlabs.
the class DistributionContext method newEngineProcess.
private Process newEngineProcess(Integer port, Integer redisPort) throws IOException {
// Set correct port & task manager
GraknConfig config = GraknConfig.create();
config.setConfigProperty(GraknConfigKey.SERVER_PORT, port);
config.setConfigProperty(GraknConfigKey.REDIS_HOST, ImmutableList.of(new SimpleURI("localhost", redisPort).toString()));
// To speed up tests of failure cases
config.setConfigProperty(GraknConfigKey.TASKS_RETRY_DELAY, 60);
// Write new properties to disk
File propertiesFile = new File("grakn-engine-" + port + ".properties");
propertiesFile.deleteOnExit();
config.write(propertiesFile);
// Java commands to start Engine process
String[] commands = { "java", "-cp", getClassPath(), "-Dgrakn.dir=" + EXTRACTED_DISTRIBUTION_DIRECTORY, "-Dgrakn.conf=" + propertiesFile.getAbsolutePath(), "-Dgrakn.pidfile=/tmp/grakn.pid", Grakn.class.getName(), "&" };
// Start process
ProcessBuilder processBuilder = new ProcessBuilder(commands);
if (inheritIO)
processBuilder.inheritIO();
return processBuilder.start();
}
Aggregations