mgmt: StatusServer

refs #1199

Change-Id: Idf2181dde857970f026e8147b60d09dea45007a1
diff --git a/daemon/main.cpp b/daemon/main.cpp
index f80a4bd..8abdba6 100644
--- a/daemon/main.cpp
+++ b/daemon/main.cpp
@@ -12,6 +12,7 @@
 #include "mgmt/face-manager.hpp"
 #include "mgmt/local-control-header-manager.hpp"
 #include "mgmt/strategy-choice-manager.hpp"
+#include "mgmt/status-server.hpp"
 #include "mgmt/config-file.hpp"
 
 #include <boost/filesystem.hpp>
@@ -32,6 +33,7 @@
 static FaceManager* g_faceManager;
 static LocalControlHeaderManager* g_localControlHeaderManager;
 static StrategyChoiceManager* g_strategyChoiceManager;
+static StatusServer* g_statusServer;
 static shared_ptr<InternalFace> g_internalFace;
 
 
@@ -42,7 +44,7 @@
     "%s --help\n\tshow this help and exit\n"
     "%s "
        "[--config /path/to/nfd.conf]\n"
-      "\trun forwarding daemon\n"
+       "\trun forwarding daemon\n"
        "\t--config <configuration file>]: path to configuration file\n"
     "\n",
     programName, programName
@@ -55,12 +57,12 @@
   g_options.m_showUsage = false;
   g_options.m_config = DEFAULT_CONFIG_FILE;
 
-  while (1) {
+  while (true) {
     int option_index = 0;
     static ::option long_options[] = {
-      { "help"          , no_argument      , 0, 0 },
-      { "config"        , required_argument, 0, 0 },
-      { 0               , 0                , 0, 0 }
+      { "help"   , no_argument      , 0, 0 },
+      { "config" , required_argument, 0, 0 },
+      { 0        , 0                , 0, 0 }
     };
     int c = getopt_long_only(argc, argv, "", long_options, &option_index);
     if (c == -1) break;
@@ -88,10 +90,8 @@
   ConfigFile config;
 
   g_internalFace = make_shared<InternalFace>();
-  g_forwarder->addFace(g_internalFace);
-
   g_internalFace->getValidator().setConfigFile(config);
-
+  g_forwarder->addFace(g_internalFace);
 
   g_fibManager = new FibManager(g_forwarder->getFib(),
                                 bind(&Forwarder::getFace, g_forwarder, _1),
@@ -107,6 +107,8 @@
   g_strategyChoiceManager = new StrategyChoiceManager(g_forwarder->getStrategyChoice(),
                                                       g_internalFace);
 
+  g_statusServer = new StatusServer(g_internalFace, *g_forwarder);
+
   config.parse(g_options.m_config, true);
   config.parse(g_options.m_config, false);
 
@@ -117,17 +119,17 @@
 int
 main(int argc, char** argv)
 {
-  try {
-    bool isCommandLineValid = parseCommandLine(argc, argv);
-    if (!isCommandLineValid) {
-      usage(argv[0]);
-      return 1;
-    }
-    if (g_options.m_showUsage) {
-      usage(argv[0]);
-      return 0;
-    }
+  bool isCommandLineValid = parseCommandLine(argc, argv);
+  if (!isCommandLineValid) {
+    usage(argv[0]);
+    return 1;
+  }
+  if (g_options.m_showUsage) {
+    usage(argv[0]);
+    return 0;
+  }
 
+  try {
     g_forwarder = new Forwarder();
     initializeMgmt();
 
@@ -138,15 +140,18 @@
   //   NFD_LOG_ERROR("Error: " << error.what());
   //   NFD_LOG_ERROR("You should either specify --config option or copy sample configuration into "
   //                 << DEFAULT_CONFIG_FILE);
-  } catch(boost::filesystem::filesystem_error& error) {
-    if (error.code() == boost::system::errc::permission_denied) {
-      NFD_LOG_ERROR("Error: Permissions denied for " << error.path1());
+  }
+  catch (boost::filesystem::filesystem_error& e) {
+    if (e.code() == boost::system::errc::permission_denied) {
+      NFD_LOG_ERROR("Error: Permissions denied for " << e.path1());
       NFD_LOG_ERROR(argv[0] << " should be run as superuser");
-    } else {
-      NFD_LOG_ERROR("Error: " << error.what());
     }
-  } catch(std::exception& exception) {
-    NFD_LOG_ERROR("Error: " << exception.what());
+    else {
+      NFD_LOG_ERROR("Error: " << e.what());
+    }
+  }
+  catch (std::exception& e) {
+    NFD_LOG_ERROR("Error: " << e.what());
     return 1;
   }
 
@@ -160,3 +165,4 @@
 {
   return nfd::main(argc, argv);
 }
+