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

ASF GitHub Bot commented on MINIFICPP-37:
-----------------------------------------

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

    https://github.com/apache/nifi-minifi-cpp/pull/237#discussion_r161255479
  
    --- Diff: controller/MiNiFiController.cpp ---
    @@ -0,0 +1,196 @@
    +/**
    + *
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *     http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +#include <fcntl.h>
    +#include <stdio.h>
    +#include <semaphore.h>
    +#include <signal.h>
    +#include <vector>
    +#include <queue>
    +#include <map>
    +#include <unistd.h>
    +#include <yaml-cpp/yaml.h>
    +#include <iostream>
    +#include "io/BaseStream.h"
    +
    +#include "core/Core.h"
    +
    +#include "core/FlowConfiguration.h"
    +#include "core/ConfigurationFactory.h"
    +#include "core/RepositoryFactory.h"
    +#include "FlowController.h"
    +#include "Main.h"
    +
    +#include "Controller.h"
    +#include "c2/ControllerSocketProtocol.h"
    +
    +#include "cxxopts.hpp"
    +
    +int main(int argc, char **argv) {
    +
    +  std::shared_ptr<logging::Logger> logger = 
logging::LoggerConfiguration::getConfiguration().getLogger("controller");
    +
    +  // assumes POSIX compliant environment
    +  std::string minifiHome;
    +  if (const char *env_p = std::getenv(MINIFI_HOME_ENV_KEY)) {
    +    minifiHome = env_p;
    +    logger->log_info("Using MINIFI_HOME=%s from environment.", minifiHome);
    +  } else {
    +    logger->log_info("MINIFI_HOME is not set; determining based on 
environment.");
    +    char *path = nullptr;
    +    char full_path[PATH_MAX];
    +    path = realpath(argv[0], full_path);
    +
    +    if (path != nullptr) {
    +      std::string minifiHomePath(path);
    +      if (minifiHomePath.find_last_of("/\\") != std::string::npos) {
    +        minifiHomePath = minifiHomePath.substr(0, 
minifiHomePath.find_last_of("/\\"));  //Remove /minifi from path
    +        minifiHome = minifiHomePath.substr(0, 
minifiHomePath.find_last_of("/\\"));    //Remove /bin from path
    +      }
    +    }
    +
    +    // attempt to use cwd as MINIFI_HOME
    +    if (minifiHome.empty() || !validHome(minifiHome)) {
    +      char cwd[PATH_MAX];
    +      getcwd(cwd, PATH_MAX);
    +      minifiHome = cwd;
    +    }
    +
    +  }
    +
    +  if (!validHome(minifiHome)) {
    +    logger->log_error("No valid MINIFI_HOME could be inferred. "
    +                      "Please set MINIFI_HOME or run minifi from a valid 
location.");
    +    return -1;
    +  }
    +
    +  std::shared_ptr<minifi::Configure> configuration = 
std::make_shared<minifi::Configure>();
    +  configuration->setHome(minifiHome);
    +  configuration->loadConfigureFile(DEFAULT_NIFI_PROPERTIES_FILE);
    +
    +  std::shared_ptr<logging::LoggerProperties> log_properties = 
std::make_shared<logging::LoggerProperties>();
    +  log_properties->setHome(minifiHome);
    +  log_properties->loadConfigureFile(DEFAULT_LOG_PROPERTIES_FILE);
    +  
logging::LoggerConfiguration::getConfiguration().initialize(log_properties);
    +
    +  auto stream_factory_ = 
std::make_shared<minifi::io::StreamFactory>(configuration);
    +
    +  std::string host, port, caCert;
    +
    +  if (!configuration->get("controller.socket.host", host) || 
!configuration->get("controller.socket.port", port)) {
    --- End diff --
    
    This was one of the big things I wanted feedback on....primarily because 
this depends highly on the use case. The reason It is not an option now is 
because the socket is limited to the loopback adapter, thus making an option 
irrelevant. If we add make it configurable so that the deployment can use a 
socket bound to any interface on that host, we could support an option in 
minificontroller. I'll make this change making the default only work on local 
host and allowing it to be changed in the minifi.properties


> Create scripts to get information from the controller API
> ---------------------------------------------------------
>
>                 Key: MINIFICPP-37
>                 URL: https://issues.apache.org/jira/browse/MINIFICPP-37
>             Project: NiFi MiNiFi C++
>          Issue Type: Sub-task
>            Reporter: marco polo
>            Assignee: marco polo
>            Priority: Minor
>              Labels: Durability, Reliability
>             Fix For: 0.4.0
>
>




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

Reply via email to