server_main.cpp
Go to the documentation of this file.
1 
11 #ifdef _WIN32
12 #include <windows.h>
13 #endif
14 
16 #include "daemon.h"
17 #include "server_options.h"
18 
19 #include <thread>
20 #include <iostream>
21 
22 /*
23 #ifdef _WIN32
24 
25 int CALLBACK WinMain(_In_ HINSTANCE hInstance, _In_ HINSTANCE hPrevInstance, _In_ LPSTR lpCmdLine, _In_ int nCmdShow)
26 {
27  int argc = __argc;
28  char** argv = __argv;
29 
30 #else
31 */
32 int main(int argc, char ** argv)
33 {
34 //#endif
35  auto logger = spdlog::stderr_color_mt("server");
36  logger->set_level(spdlog::level::info);
37 
38  try
39  {
40  const char ** arv = (const char **)argv;
41  OpcUa::Server::CommandLine options(argc, arv);
42 
43  if (!options.NeedStartServer())
44  {
45  return 0;
46  }
47 
48  OpcUa::Daemon daemon;
49 
50  if (options.IsDaemonMode())
51  {
52  daemon.Daemonize(options.GetLogFile());
53  }
54 
55  Common::AddonsManager::UniquePtr manager = Common::CreateAddonsManager(logger);
57 
58  manager->Start();
59  daemon.WaitForTerminate();
60  manager->Stop();
61 
62  return 0;
63  }
64 
65  catch (const std::exception & exc)
66  {
67  std::cout << exc.what() << std::endl;
68  }
69 
70  catch (...)
71  {
72  std::cout << "Unknown error." << std::endl;
73  }
74 
75  return -1;
76 }
77 
void LoadConfiguration(const std::string &configDirectoryPath, Common::AddonsManager &addons)
Load parameters from configuration files. This function will enumerate &#39;*.config&#39; files in the direct...
void WaitForTerminate()
Definition: daemon.cpp:26
std::string GetLogFile() const
AddonsManager::UniquePtr CreateAddonsManager(const Common::Logger::SharedPtr &logger)
Get instance of addons core.
std::string GetConfigDir() const
void Daemonize(const std::string &str)
Definition: daemon_lin.cpp:68
int main(int argc, char **argv)
OPC UA Server main. GNU LGPL.
Definition: server_main.cpp:32
std::shared_ptr< logger > stderr_color_mt(const std::string &logger_name)
Definition: spdlog_impl.h:150


ros_opcua_impl_freeopcua
Author(s): Denis Štogl
autogenerated on Tue Jan 19 2021 03:12:07