-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.cpp
More file actions
114 lines (102 loc) · 3.9 KB
/
main.cpp
File metadata and controls
114 lines (102 loc) · 3.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#include <appbase/application.hpp>
#include <boost/dll/runtime_symbol_info.hpp>
#include <boost/exception/diagnostic_information.hpp>
#include <eosio/version/version.hpp>
#include <fc/exception/exception.hpp>
#include <fc/filesystem.hpp>
#include <fc/log/logger.hpp>
#include <fc/log/logger_config.hpp>
#include "cloner_plugin.hpp"
#include "config.hpp"
#include "wasm_ql_plugin.hpp"
using namespace appbase;
namespace detail {
void configure_logging(const bfs::path& config_path) {
try {
try {
fc::configure_logging(config_path);
} catch (...) {
elog("Error reloading logging.json");
throw;
}
} catch (const fc::exception& e) { //
elog("{e}", ("e", e.to_detail_string()));
} catch (const boost::exception& e) {
elog("{e}", ("e", boost::diagnostic_information(e)));
} catch (const std::exception& e) { //
elog("{e}", ("e", e.what()));
} catch (...) {
// empty
}
}
} // namespace detail
void logging_conf_handler() {
auto config_path = app().get_logging_conf();
if (fc::exists(config_path)) {
ilog("Received HUP. Reloading logging configuration from {p}.", ("p", config_path.string()));
} else {
ilog("Received HUP. No log config found at {p}, setting to default.", ("p", config_path.string()));
}
::detail::configure_logging(config_path);
}
void initialize_logging() {
auto config_path = app().get_logging_conf();
if (fc::exists(config_path))
fc::configure_logging(config_path); // intentionally allowing exceptions to escape
app().set_sighup_callback(logging_conf_handler);
}
enum return_codes {
other_fail = -2,
initialize_fail = -1,
success = 0,
bad_alloc = 1,
};
int main(int argc, char** argv) {
try {
app().set_version(b1::rodeos::config::version);
app().set_version_string(eosio::version::version_client());
app().set_full_version_string(eosio::version::version_full());
auto root = fc::app_path();
app().set_default_data_dir(root / "eosio" / b1::rodeos::config::rodeos_executable_name / "data");
app().set_default_config_dir(root / "eosio" / b1::rodeos::config::rodeos_executable_name / "config");
if (!app().initialize<b1::cloner_plugin, b1::wasm_ql_plugin>(argc, argv)) {
const auto& opts = app().get_options();
if (opts.count("help") || opts.count("version") || opts.count("full-version") ||
opts.count("print-default-config")) {
return success;
}
return initialize_fail;
}
initialize_logging();
ilog("{name} version {ver} {fv}",
("name", b1::rodeos::config::rodeos_executable_name)("ver", app().version_string())(
"fv", app().version_string() == app().full_version_string() ? "" : app().full_version_string()));
ilog("{name} using configuration file {c}",
("name", b1::rodeos::config::rodeos_executable_name)("c", app().full_config_file_path().string()));
ilog("{name} data directory is {d}",
("name", b1::rodeos::config::rodeos_executable_name)("d", app().data_dir().string()));
app().startup();
app().set_thread_priority_max();
app().exec();
} catch (const fc::std_exception_wrapper& e) {
elog("{e}", ("e", e.to_detail_string()));
return other_fail;
} catch (const fc::exception& e) {
elog("{e}", ("e", e.to_detail_string()));
return other_fail;
} catch (const boost::interprocess::bad_alloc& e) {
elog("bad alloc");
return bad_alloc;
} catch (const boost::exception& e) {
elog("{e}", ("e", boost::diagnostic_information(e)));
return other_fail;
} catch (const std::exception& e) {
elog("{e}", ("e", e.what()));
return other_fail;
} catch (...) {
elog("unknown exception");
return other_fail;
}
ilog("{name} successfully exiting", ("name", b1::rodeos::config::rodeos_executable_name));
return success;
}