[ 
https://issues.apache.org/jira/browse/NIFIREG-6?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16112784#comment-16112784
 ] 

ASF GitHub Bot commented on NIFIREG-6:
--------------------------------------

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.


> Add nifi-registry-bootstrap module
> ----------------------------------
>
>                 Key: NIFIREG-6
>                 URL: https://issues.apache.org/jira/browse/NIFIREG-6
>             Project: NiFi Registry
>          Issue Type: Improvement
>    Affects Versions: 0.0.1
>            Reporter: Bryan Bende
>            Assignee: Bryan Bende
>            Priority: Minor
>
> Currently NiFiRegistry is the entry point of the application, and in its 
> current state the main method starts a new Jetty server every time.  
> We should take a similar approach to NiFi where we have a bootstrap process 
> that launches and communicates with the application process.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to