Github user alopresto commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/386#discussion_r62083303
  
    --- Diff: 
nifi-bootstrap/src/main/java/org/apache/nifi/bootstrap/RunNiFi.java ---
    @@ -324,27 +324,46 @@ private void registerNotificationServices(final 
NotificationServiceManager manag
             defaultLogger.info("Registered {} Notification Services for 
Notification Type {}", registered, type);
         }
     
    -    File getStatusFile() {
    +    File getStatusFile() throws IOException{
             return getStatusFile(defaultLogger);
         }
     
    -    public File getStatusFile(final Logger logger) {
    +    public File getStatusFile(final Logger logger) throws IOException{
             final File confDir = bootstrapConfigFile.getParentFile();
             final File nifiHome = confDir.getParentFile();
    -        final File bin = new File(nifiHome, "bin");
    -        final File statusFile = new File(bin, "nifi.pid");
     
    -        logger.debug("Status File: {}", statusFile);
    +        String pidDir = System.getProperty(NIFI_PID_DIR_PROP);
    +
    +        final File pidFileDir;
     
    +        if(pidDir != null){
    +            pidFileDir = new File(pidDir.trim());
    +        } else{
    +            pidFileDir = new File(nifiHome, DEFAULT_PID_DIR);
    +        }
    +
    +        FileUtils.ensureDirectoryExistAndCanAccess(pidFileDir);
    +        final File statusFile = new File(pidFileDir, "nifi.pid");
    +        logger.debug("Status File: {}", statusFile);
             return statusFile;
         }
     
    -    public File getLockFile(final Logger logger) {
    +    public File getLockFile(final Logger logger) throws IOException{
    --- End diff --
    
    This method's logic is identical to the one above with the exception of the 
file extension. To reduce code duplication, perhaps we could provide a private 
method with the logic that just accepts the filename, and both could invoke 
that with a hard-coded value (even better, constants). 


---
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.
---

Reply via email to