Skip to content

Commit

Permalink
Fix server startup when Etc directory does not exist
Browse files Browse the repository at this point in the history
`launcher`'s `--etc-dir` is optional and so `./etc` directory may not
exist.
  • Loading branch information
findepi committed Mar 11, 2019
1 parent f4ce2a2 commit a26aa10
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions presto-main/src/main/java/io/prestosql/server/PrestoServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@
import io.prestosql.sql.parser.SqlParserOptions;
import org.weakref.jmx.guice.MBeanModule;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.LinkedHashSet;
import java.util.List;
Expand All @@ -56,6 +59,7 @@
import static io.airlift.discovery.client.ServiceAnnouncement.serviceAnnouncement;
import static io.prestosql.server.PrestoSystemRequirements.verifyJvmRequirements;
import static io.prestosql.server.PrestoSystemRequirements.verifySystemTimeIsReasonable;
import static java.nio.file.LinkOption.NOFOLLOW_LINKS;
import static java.util.Objects.requireNonNull;

public class PrestoServer
Expand Down Expand Up @@ -115,8 +119,8 @@ public void run()
try {
Injector injector = app.strictConfig().initialize();

log.info("Working directory: %s", Paths.get(".").toAbsolutePath().toRealPath());
log.info("Etc directory: %s", Paths.get("etc").toAbsolutePath().toRealPath());
logLocation(log, "Working directory", Paths.get("."));
logLocation(log, "Etc directory", Paths.get("etc"));

injector.getInstance(PluginManager.class).loadPlugins();

Expand Down Expand Up @@ -195,4 +199,20 @@ private static ServiceAnnouncement getPrestoAnnouncement(Set<ServiceAnnouncement
}
throw new IllegalArgumentException("Presto announcement not found: " + announcements);
}

private static void logLocation(Logger log, String name, Path path)
{
if (!Files.exists(path, NOFOLLOW_LINKS)) {
log.info("%s: [does not exist]", name);
return;
}
try {
path = path.toAbsolutePath().toRealPath();
}
catch (IOException e) {
log.info("%s: [not accessible]", name);
return;
}
log.info("%s: %s", name, path);
}
}

0 comments on commit a26aa10

Please sign in to comment.