Changeset View
Changeset View
Standalone View
Standalone View
src/bitcoind.cpp
Show First 20 Lines • Show All 129 Lines • ▼ Show 20 Lines | try { | ||||
fprintf(stderr, "Error: Command line contains unexpected token " | fprintf(stderr, "Error: Command line contains unexpected token " | ||||
"'%s', see bitcoind -h for a list of " | "'%s', see bitcoind -h for a list of " | ||||
"options.\n", | "options.\n", | ||||
argv[i]); | argv[i]); | ||||
exit(EXIT_FAILURE); | exit(EXIT_FAILURE); | ||||
} | } | ||||
} | } | ||||
// Make sure we setup and lock data dir after daemonization | |||||
ParameterSetup(); | |||||
if (!AppInitBase(config, rpcServer)) { | |||||
// InitError will have been called with detailed error, which ends | |||||
// up on console | |||||
exit(EXIT_FAILURE); | |||||
} | |||||
// -server defaults to true for bitcoind but not for the GUI so do this | // -server defaults to true for bitcoind but not for the GUI so do this | ||||
// here | // here | ||||
gArgs.SoftSetBoolArg("-server", true); | gArgs.SoftSetBoolArg("-server", true); | ||||
// Set this early so that parameter interactions go to console | // Set this early so that parameter interactions go to console | ||||
InitLogging(); | |||||
InitParameterInteraction(); | |||||
if (!AppInitBasicSetup()) { | |||||
// InitError will have been called with detailed error, which ends | |||||
// up on console | |||||
exit(1); | |||||
} | |||||
if (!AppInitParameterInteraction(config, rpcServer)) { | |||||
// InitError will have been called with detailed error, which ends | |||||
// up on console | |||||
exit(1); | |||||
} | |||||
if (!AppInitSanityChecks()) { | |||||
// InitError will have been called with detailed error, which ends | |||||
// up on console | |||||
exit(1); | |||||
} | |||||
if (gArgs.GetBoolArg("-daemon", false)) { | if (gArgs.GetBoolArg("-daemon", false)) { | ||||
#if HAVE_DECL_DAEMON | #if HAVE_DECL_DAEMON | ||||
fprintf(stdout, "Bitcoin server starting\n"); | fprintf(stdout, "Bitcoin server starting\n"); | ||||
// Daemonize | // Daemonize | ||||
if (daemon(1, 0)) { | if (daemon(1, 0)) { | ||||
// don't chdir (1), do close FDs (0) | // don't chdir (1), do close FDs (0) | ||||
fprintf(stderr, "Error: daemon() failed: %s\n", | fprintf(stderr, "Error: daemon() failed: %s\n", | ||||
strerror(errno)); | strerror(errno)); | ||||
return false; | return false; | ||||
} | } | ||||
#else | #else | ||||
fprintf( | fprintf( | ||||
stderr, | stderr, | ||||
"Error: -daemon is not supported on this operating system\n"); | "Error: -daemon is not supported on this operating system\n"); | ||||
return false; | return false; | ||||
#endif // HAVE_DECL_DAEMON | #endif // HAVE_DECL_DAEMON | ||||
} | } | ||||
// Lock data directory after daemonization | // Lock data directory after daemonization | ||||
if (!AppInitLockDataDirectory()) { | if (!AppInitLockDataDirectory()) { | ||||
// If locking the data directory failed, exit immediately | |||||
exit(EXIT_FAILURE); | exit(EXIT_FAILURE); | ||||
} | } | ||||
fRet = AppInitMain(config, httpRPCRequestProcessor, threadGroup, | fRet = AppInitMain(config, httpRPCRequestProcessor, threadGroup, | ||||
scheduler); | scheduler); | ||||
} catch (const std::exception &e) { | } catch (const std::exception &e) { | ||||
PrintExceptionContinue(&e, "AppInit()"); | PrintExceptionContinue(&e, "AppInit()"); | ||||
} catch (...) { | } catch (...) { | ||||
PrintExceptionContinue(nullptr, "AppInit()"); | PrintExceptionContinue(nullptr, "AppInit()"); | ||||
Show All 24 Lines |