Main.java 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. package uk.ac.ic.wlgitbridge;
  2. import java.net.InetAddress;
  3. import java.net.UnknownHostException;
  4. import java.util.Arrays;
  5. import uk.ac.ic.wlgitbridge.application.GitBridgeApp;
  6. import uk.ac.ic.wlgitbridge.util.Log;
  7. /*
  8. * Created by Winston on 01/11/14.
  9. */
  10. /*
  11. * This is the entry point into the Git Bridge.
  12. *
  13. * It is responsible for creating the {@link GitBridgeApp} and then running it.
  14. *
  15. * The {@link GitBridgeApp} parses args and creates the {@link GitBridgeServer}.
  16. *
  17. * The {@link GitBridgeServer} creates the {@link Bridge}, among other things.
  18. *
  19. * The {@link Bridge} is the heart of the Git Bridge. Start there, and follow
  20. * the links outwards (which lead back to the Git users and the postback from
  21. * the snapshot API) and inwards (which lead into the components of the Git
  22. * Bridge: the configurable repo store, db store, and swap store, along with
  23. * the project lock, the swap job, the snapshot API, the resource cache
  24. * and the postback manager).
  25. */
  26. public class Main {
  27. public static void main(String[] args) {
  28. if ("gke".equals(System.getenv("LOGGING_FORMAT"))) {
  29. System.setProperty("logback.configurationFile", "logback-gke.xml");
  30. }
  31. String hostname = System.getenv("HOSTNAME");
  32. if (hostname == null || hostname.isEmpty()) {
  33. try {
  34. hostname = InetAddress.getLocalHost().getHostName();
  35. } catch (UnknownHostException e) {
  36. hostname = "unknown";
  37. }
  38. }
  39. System.setProperty("HOSTNAME", hostname);
  40. System.setProperty("PID", String.valueOf(ProcessHandle.current().pid()));
  41. Log.info("Git Bridge started with args: " + Arrays.toString(args));
  42. try {
  43. new GitBridgeApp(args).run();
  44. } catch (Throwable t) {
  45. /* So that we get a timestamp */
  46. Log.error("Fatal exception thrown to top level, exiting: ", t);
  47. System.exit(1);
  48. }
  49. }
  50. }