Github user mcgilman commented on a diff in the pull request:
https://github.com/apache/nifi-registry/pull/3#discussion_r131150677
--- Diff:
nifi-registry-runtime/src/main/java/org/apache/nifi/registry/NiFiRegistry.java
---
@@ -43,28 +90,242 @@ public void run() {
}
}));
- // load the properties
+ final String bootstrapPort =
System.getProperty(BOOTSTRAP_PORT_PROPERTY);
+ if (bootstrapPort != null) {
+ try {
+ final int port = Integer.parseInt(bootstrapPort);
+
+ if (port < 1 || port > 65535) {
+ throw new RuntimeException("Failed to start NiFi
Registry because system property '" + BOOTSTRAP_PORT_PROPERTY + "' is not a
valid integer in the range 1 - 65535");
+ }
+
+ bootstrapListener = new BootstrapListener(this, port);
+ bootstrapListener.start();
+ } catch (final NumberFormatException nfe) {
+ throw new RuntimeException("Failed to start NiFi Registry
because system property '" + BOOTSTRAP_PORT_PROPERTY + "' is not a valid
integer in the range 1 - 65535");
+ }
+ } else {
+ LOGGER.info("NiFi Registry started without Bootstrap Port
information provided; will not listen for requests from Bootstrap");
+ bootstrapListener = null;
+ }
+
+ // delete the web working dir - if the application does not start
successfully
+ // the web app directories might be in an invalid state. when this
happens
+ // jetty will not attempt to re-extract the war into the
directory. by removing
+ // the working directory, we can be assured that it will attempt
to extract the
+ // war every time the application starts.
+ File webWorkingDir = properties.getWebWorkingDirectory();
+ FileUtils.deleteFilesInDirectory(webWorkingDir, null, LOGGER,
true, true);
+ FileUtils.deleteFile(webWorkingDir, LOGGER, 3);
+
+ detectTimingIssues();
+
+ // redirect JUL log events
+ SLF4JBridgeHandler.removeHandlersForRootLogger();
+ SLF4JBridgeHandler.install();
+
+ final long startTime = System.nanoTime();
+ server = new JettyServer(properties);
+
+ if (shutdown) {
+ LOGGER.info("NiFi Registry has been shutdown via NiFi Registry
Bootstrap. Will not start Controller");
+ } else {
+ server.start();
+
+ if (bootstrapListener != null) {
+ bootstrapListener.sendStartedStatus(true);
+ }
+
+ final long duration = System.nanoTime() - startTime;
+ LOGGER.info("Controller initialization took " + duration + "
nanoseconds "
+ + "(" + (int) TimeUnit.SECONDS.convert(duration,
TimeUnit.NANOSECONDS) + " seconds).");
+ }
+ }
+
+ protected void shutdownHook() {
+ try {
+ this.shutdown = true;
+
+ LOGGER.info("Initiating shutdown of Jetty web server...");
+ if (server != null) {
+ server.stop();
+ }
+ if (bootstrapListener != null) {
+ bootstrapListener.stop();
+ }
+ LOGGER.info("Jetty web server shutdown completed (nicely or
otherwise).");
+ } catch (final Throwable t) {
+ LOGGER.warn("Problem occurred ensuring Jetty web server was
properly terminated due to " + t);
+ }
+ }
+
+ /**
+ * Determine if the machine we're running on has timing issues.
+ */
+ private void detectTimingIssues() {
--- End diff --
I'm not sure we need to detect timing issues for the registry. Can probably
remove this check.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---