113{
114 try {
115
116
117
119
121
122
123 po::options_description all_options("All");
124 po::options_description hidden_options("Hidden");
125 po::options_description visible_options("Options");
126 po::options_description core_settings("Settings");
127 po::positional_options_description positional_options;
128 {
129
130
135
136
146
149
150
152
153 visible_options.add(core_settings);
154 all_options.add(visible_options);
155 all_options.add(hidden_options);
156
157
159 }
160
161
162 po::variables_map vm;
164 {
165 boost::program_options::store(
166 boost::program_options::command_line_parser(argc, argv)
167 .options(all_options).positional(positional_options).run()
168 , vm
169 );
170
171 return true;
172 });
173 if (!ok) return 1;
174
176 {
178 std::cout << "Usage: " + std::string{argv[0]} + " [options|settings] [daemon_command...]" << std::endl << std::endl;
179 std::cout << visible_options << std::endl;
180 return 0;
181 }
182
183
185 {
187 return 0;
188 }
189
190
192 {
194 return 0;
195 }
196
198 boost::filesystem::path config_path(
config);
199 boost::system::error_code ec;
200 if (bf::exists(config_path, ec))
201 {
202 try
203 {
204 po::store(po::parse_config_file<char>(config_path.string<std::string>().c_str(), core_settings), vm);
205 }
206 catch (const std::exception &e)
207 {
208
209 std::cerr << "Error parsing config file: " << e.what() << std::endl;
210 throw;
211 }
212 }
214 {
215 std::cerr <<
"Can't find config file " <<
config << std::endl;
216 return 1;
217 }
218
222 if (testnet + stagenet + regtest > 1)
223 {
224 std::cerr <<
"Can't specify more than one of --tesnet and --stagenet and --regtest" <<
ENDL;
225 return 1;
226 }
227
229
230
232 {
233 std::cout << "Invalid database type (" << db_type << "), available types are: " <<
235 return 0;
236 }
237
238
239
240
241
242
243
244
245 boost::filesystem::path
data_dir = boost::filesystem::absolute(
247
248
249
250 bf::path relative_path_base =
data_dir;
251
252 po::notify(vm);
253
254
255
256
257
258
262 if (!log_file_path.has_parent_path())
263 log_file_path = bf::absolute(log_file_path, relative_path_base);
265
266
268 {
270 }
271
272
274
275#ifdef STACK_TRACE
277#endif
278
281
282
283 {
285
286 if (command.size())
287 {
291
295 {
296 std::cerr << "Invalid IP: " << rpc_ip_str << std::endl;
297 return 1;
298 }
300 {
301 std::cerr << "Invalid port: " << rpc_port_str << std::endl;
302 return 1;
303 }
304
305 const char *env_rpc_login = nullptr;
307 const bool use_rpc_env = !has_rpc_arg && (env_rpc_login = getenv("RPC_LOGIN")) != nullptr && strlen(env_rpc_login) > 0;
308 boost::optional<tools::login> login{};
309 if (has_rpc_arg || use_rpc_env)
310 {
313#ifdef HAVE_READLINE
314 rdln::suspend_readline pause_readline;
315#endif
316 return tools::password_container::prompt(verify, "Daemon client password");
317 }
318 );
319 if (!login)
320 {
321 std::cerr << "Failed to obtain password" << std::endl;
322 return 1;
323 }
324 }
325
327 if (!ssl_options)
328 return 1;
329
332 {
333 return 0;
334 }
335 else
336 {
337#ifdef HAVE_READLINE
339#endif
340 std::cerr << "Unknown command: " << command.front() << std::endl;
341 return 1;
342 }
343 }
344 }
345
346#ifdef STACK_TRACE
348#endif
349
352
353
355
356 MINFO(
"Moving from main() into the daemonize now.");
357
359 }
360 catch (std::exception const & ex)
361 {
362 LOG_ERROR(
"Exception in main! " << ex.what());
363 }
364 catch (...)
365 {
367 }
368 return 1;
369}
static const command_line::arg_descriptor< std::string, false, true, 2 > arg_rpc_bind_port
bool process_command_vec(const std::vector< std::string > &cmd)
static void init_options(boost::program_options::options_description &configurable_options)
void mlog_configure(const std::string &filename_base, bool console, const std::size_t max_log_file_size=MAX_LOG_FILE_SIZE, const std::size_t max_log_files=MAX_LOG_FILES)
void mlog_set_log(const char *log)
void add_arg(boost::program_options::options_description &description, const arg_descriptor< T, required, dependent, NUM_DEPS > &arg, bool unique=true)
const arg_descriptor< bool > arg_help
const arg_descriptor< bool > arg_version
bool is_arg_defaulted(const boost::program_options::variables_map &vm, const arg_descriptor< T, required, dependent, NUM_DEPS > &arg)
bool handle_error_helper(const boost::program_options::options_description &desc, F parser)
std::enable_if<!std::is_same< T, bool >::value, bool >::type has_arg(const boost::program_options::variables_map &vm, const arg_descriptor< T, required, dependent, NUM_DEPS > &arg)
T get_arg(const boost::program_options::variables_map &vm, const arg_descriptor< T, false, true > &arg)
const command_line::arg_descriptor< std::string, false, true, 2 > arg_data_dir
const command_line::arg_descriptor< bool > arg_regtest_on
const command_line::arg_descriptor< bool, false > arg_testnet_on
const command_line::arg_descriptor< std::string > arg_db_type
bool blockchain_valid_db_type(const std::string &db_type)
const command_line::arg_descriptor< bool, false > arg_stagenet_on
std::string blockchain_db_types(const std::string &sep)
const command_line::arg_descriptor< std::string, false, true, 2 > arg_log_file
const command_line::arg_descriptor< std::size_t > arg_max_log_files
const command_line::arg_descriptor< std::string > arg_log_level
const command_line::arg_descriptor< std::string, false, true, 2 > arg_config_file
const command_line::arg_descriptor< bool > arg_public_node
const command_line::arg_descriptor< bool > arg_os_version
const command_line::arg_descriptor< std::vector< std::string > > arg_command
const command_line::arg_descriptor< bool > arg_zmq_rpc_disabled
const command_line::arg_descriptor< std::string, false, true, 2 > arg_zmq_rpc_bind_port
const command_line::arg_descriptor< std::string > arg_zmq_rpc_bind_ip
const command_line::arg_descriptor< unsigned > arg_max_concurrency
const command_line::arg_descriptor< std::size_t > arg_max_log_file_size
bool daemonize(int argc, char const *argv[], T_executor &&executor, boost::program_options::variables_map const &vm)
void init_options(boost::program_options::options_description &hidden_options, boost::program_options::options_description &normal_options)
boost::filesystem::path data_dir
uint16_t parse_public_rpc_port(const po::variables_map &vm)
const command_line::arg_descriptor< std::string > rpc_login
const command_line::arg_descriptor< std::string > rpc_bind_ip
static boost::optional< epee::net_utils::ssl_options_t > process_ssl(const boost::program_options::variables_map &vm, const bool any_cert_option=false)
const char *const ELECTRONEUM_RELEASE_NAME
const char *const ELECTRONEUM_VERSION_FULL