Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
main.cpp File Reference
#include <appbase/application.hpp>
#include <sysio/chain_plugin/chain_plugin.hpp>
#include <sysio/http_plugin/http_plugin.hpp>
#include <sysio/net_plugin/net_plugin.hpp>
#include <sysio/producer_plugin/producer_plugin.hpp>
#include <sysio/resource_monitor_plugin/resource_monitor_plugin.hpp>
#include <sysio/version/version.hpp>
#include <fc/log/logger.hpp>
#include <fc/log/logger_config.hpp>
#include <fc/log/appender.hpp>
#include <fc/exception/exception.hpp>
#include <boost/dll/runtime_symbol_info.hpp>
#include <boost/exception/diagnostic_information.hpp>
#include "config.hpp"
Include dependency graph for main.cpp:

Go to the source code of this file.

Namespaces

namespace  detail
 

Enumerations

enum  return_codes {
  OTHER_FAIL = -2 , INITIALIZE_FAIL = -1 , SUCCESS = 0 , BAD_ALLOC = 1 ,
  DATABASE_DIRTY = 2 , FIXED_REVERSIBLE = SUCCESS , EXTRACTED_GENESIS = SUCCESS , NODE_MANAGEMENT_SUCCESS = 5
}
 

Functions

fc::logging_configdetail::add_deep_mind_logger (fc::logging_config &config)
 
void detail::configure_logging (const bfs::path &config_path)
 
void logging_conf_handler ()
 
void initialize_logging ()
 
int main (int argc, char **argv)
 

Enumeration Type Documentation

◆ return_codes

Enumerator
OTHER_FAIL 
INITIALIZE_FAIL 
SUCCESS 
BAD_ALLOC 
DATABASE_DIRTY 
FIXED_REVERSIBLE 
EXTRACTED_GENESIS 
NODE_MANAGEMENT_SUCCESS 

Definition at line 97 of file main.cpp.

97 {
98 OTHER_FAIL = -2,
99 INITIALIZE_FAIL = -1,
100 SUCCESS = 0,
101 BAD_ALLOC = 1,
102 DATABASE_DIRTY = 2,
106};
@ FIXED_REVERSIBLE
Definition main.cpp:103
@ INITIALIZE_FAIL
Definition main.cpp:99
@ DATABASE_DIRTY
Definition main.cpp:102
@ NODE_MANAGEMENT_SUCCESS
Definition main.cpp:105
@ BAD_ALLOC
Definition main.cpp:101
@ EXTRACTED_GENESIS
Definition main.cpp:104
@ OTHER_FAIL
Definition main.cpp:98
@ SUCCESS
Definition main.cpp:100

Function Documentation

◆ initialize_logging()

void initialize_logging ( )

Definition at line 81 of file main.cpp.

82{
83 auto config_path = app().get_logging_conf();
84 if(fc::exists(config_path))
85 fc::configure_logging(config_path); // intentionally allowing exceptions to escape
86 else {
88
90 }
91
92 fc::log_config::initialize_appenders( app().get_io_service() );
93
95}
void set_sighup_callback(std::function< void()> callback)
Set function pointer invoked on receipt of SIGHUP.
bfs::path get_logging_conf() const
Get logging configuration path.
application & app()
fc::logging_config & add_deep_mind_logger(fc::logging_config &config)
Definition main.cpp:25
bool exists(const path &p)
void configure_logging(const fc::path &log_config)
void logging_conf_handler()
Definition main.cpp:69
static void initialize_appenders(boost::asio::io_service &ios)
static logging_config default_config()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ logging_conf_handler()

void logging_conf_handler ( )

Definition at line 69 of file main.cpp.

70{
71 auto config_path = app().get_logging_conf();
72 if( fc::exists( config_path ) ) {
73 ilog( "Received HUP. Reloading logging configuration from ${p}.", ("p", config_path.string()) );
74 } else {
75 ilog( "Received HUP. No log config found at ${p}, setting to default.", ("p", config_path.string()) );
76 }
77 ::detail::configure_logging( config_path );
78 fc::log_config::initialize_appenders( app().get_io_service() );
79}
#define ilog(FORMAT,...)
Definition logger.hpp:118
void configure_logging(const bfs::path &config_path)
Definition main.cpp:41
Here is the call graph for this function:
Here is the caller graph for this function:

◆ main()

int main ( int argc,
char ** argv )

Definition at line 108 of file main.cpp.

109{
110 try {
111 app().set_version(sysio::nodeop::config::version);
114
115 auto root = fc::app_path();
116 app().set_default_data_dir(root / "sysio" / nodeop::config::node_executable_name / "data" );
117 app().set_default_config_dir(root / "sysio" / nodeop::config::node_executable_name / "config" );
119 .default_unix_socket_path = "",
120 .default_http_port = 8888
121 });
122 if(!app().initialize<chain_plugin, net_plugin, producer_plugin, resource_monitor_plugin>(argc, argv)) {
123 const auto& opts = app().get_options();
124 if( opts.count("help") || opts.count("version") || opts.count("full-version") || opts.count("print-default-config") ) {
125 return SUCCESS;
126 }
127 return INITIALIZE_FAIL;
128 }
129 if (auto resmon_plugin = app().find_plugin<resource_monitor_plugin>()) {
130 resmon_plugin->monitor_directory(app().data_dir());
131 } else {
132 elog("resource_monitor_plugin failed to initialize");
133 return INITIALIZE_FAIL;
134 }
136 ilog( "${name} version ${ver} ${fv}",
137 ("name", nodeop::config::node_executable_name)("ver", app().version_string())
138 ("fv", app().version_string() == app().full_version_string() ? "" : app().full_version_string()) );
139 ilog("${name} using configuration file ${c}", ("name", nodeop::config::node_executable_name)("c", app().full_config_file_path().string()));
140 ilog("${name} data directory is ${d}", ("name", nodeop::config::node_executable_name)("d", app().data_dir().string()));
141 app().startup();
143 app().exec();
144 } catch( const extract_genesis_state_exception& e ) {
145 return EXTRACTED_GENESIS;
146 } catch( const fixed_reversible_db_exception& e ) {
147 return FIXED_REVERSIBLE;
148 } catch( const node_management_success& e ) {
150 } catch( const fc::exception& e ) {
151 if( e.code() == fc::std_exception_code ) {
152 if( e.top_message().find( "atabase dirty flag set" ) != std::string::npos ) {
153 elog( "database dirty flag set (likely due to unclean shutdown): replay required" );
154 return DATABASE_DIRTY;
155 }
156 }
157 elog( "${e}", ("e", e.to_detail_string()));
158 return OTHER_FAIL;
159 } catch( const boost::interprocess::bad_alloc& e ) {
160 elog("bad alloc");
161 return BAD_ALLOC;
162 } catch( const boost::exception& e ) {
163 elog("${e}", ("e",boost::diagnostic_information(e)));
164 return OTHER_FAIL;
165 } catch( const std::runtime_error& e ) {
166 if( std::string(e.what()).find("atabase dirty flag set") != std::string::npos ) {
167 elog( "database dirty flag set (likely due to unclean shutdown): replay required" );
168 return DATABASE_DIRTY;
169 } else {
170 elog( "${e}", ("e",e.what()));
171 }
172 return OTHER_FAIL;
173 } catch( const std::exception& e ) {
174 elog("${e}", ("e",e.what()));
175 return OTHER_FAIL;
176 } catch( ... ) {
177 elog("unknown exception");
178 return OTHER_FAIL;
179 }
180
181 ilog("${name} successfully exiting", ("name", nodeop::config::node_executable_name));
182 return SUCCESS;
183}
const bpo::variables_map & get_options() const
void set_version_string(std::string v)
User provided version string for version_string() which overrides git describe value.
void set_version(uint64_t version)
Set version.
void set_default_config_dir(const bfs::path &config_dir="etc")
Set default config directory.
void set_full_version_string(std::string v)
User provided full version string for full_version_string()
void set_default_data_dir(const bfs::path &data_dir="data-dir")
Set default data directory.
Used to generate a useful error report when an exception is thrown.
Definition exception.hpp:58
std::string to_detail_string(log_level ll=log_level::all) const
int64_t code() const
std::string top_message() const
static void set_defaults(const http_plugin_defaults config)
char ** argv
#define elog(FORMAT,...)
Definition logger.hpp:130
const path & app_path()
@ std_exception_code
Definition exception.hpp:32
const std::string & version_client()
< Grab the basic version information of the client; example: v1.8.0-rc1
Definition version.cpp:5
const std::string & version_full()
Definition version.cpp:10
void initialize_logging()
Definition main.cpp:81
Here is the call graph for this function: