14 #include <boost/algorithm/string/predicate.hpp>
15 #include <boost/filesystem.hpp>
46 threadGroup->interrupt_all();
47 threadGroup->join_all();
57 boost::thread_group threadGroup;
58 boost::thread* detectShutdownThread = NULL;
68 if (!boost::filesystem::is_directory(
GetDataDir(
false)))
70 fprintf(stderr,
"Error: Specified data directory \"%s\" does not exist.\n",
mapArgs[
"-datadir"].c_str());
76 }
catch(std::exception &e) {
77 fprintf(stderr,
"Error reading configuration file: %s\n", e.what());
82 fprintf(stderr,
"Error: Invalid combination of -regtest and -testnet.\n");
89 std::string strUsage =
_(
"Bitcoin Core Daemon") +
" " +
_(
"version") +
" " +
FormatFullVersion() +
"\n\n" +
91 " bitcoind [options] " +
_(
"Start Bitcoin Core Daemon") +
"\n" +
92 _(
"Usage (deprecated, use bitcoin-cli):") +
"\n" +
93 " bitcoind [options] <command> [params] " +
_(
"Send command to Bitcoin Core") +
"\n" +
94 " bitcoind [options] help " +
_(
"List commands") +
"\n" +
95 " bitcoind [options] help <command> " +
_(
"Get help for a command") +
"\n";
100 fprintf(stdout,
"%s", strUsage.c_str());
105 bool fCommandLine =
false;
106 for (
int i = 1; i < argc; i++)
107 if (!
IsSwitchChar(argv[i][0]) && !boost::algorithm::istarts_with(argv[i],
"bitcoin:"))
119 fprintf(stdout,
"Master Core server starting\n");
125 fprintf(stderr,
"Error: fork() returned %d errno %d\n", pid, errno);
135 pid_t sid = setsid();
137 fprintf(stderr,
"Error: setsid() returned %d errno %d\n", sid, errno);
145 catch (std::exception& e) {
153 if (detectShutdownThread)
154 detectShutdownThread->interrupt();
156 threadGroup.interrupt_all();
162 if (detectShutdownThread)
164 detectShutdownThread->join();
165 delete detectShutdownThread;
166 detectShutdownThread = NULL;
173 int main(
int argc,
char* argv[])
187 return (fRet ? 0 : 1);
const boost::filesystem::path & GetDataDir(bool fNetSpecific)
std::string HelpMessageCli(bool mainProgram)
Show help message for bitcoin-cli.
void CreatePidFile(const boost::filesystem::path &path, pid_t pid)
void MilliSleep(int64_t n)
bool SoftSetBoolArg(const std::string &strArg, bool fValue)
Set a boolean argument if it doesn't already have a value.
boost::filesystem::path GetPidFile()
bool SelectParamsFromCommandLine()
Looks for -regtest or -testnet and then calls SelectParams as appropriate.
void DetectShutdownThread(boost::thread_group *threadGroup)
std::string HelpMessage(HelpMessageMode hmm)
int main(int argc, char *argv[])
bool GetBoolArg(const std::string &strArg, bool fDefault)
Return boolean argument or default value.
bool AppInit2(boost::thread_group &threadGroup)
Initialize bitcoin.
void PrintExceptionContinue(std::exception *pex, const char *pszThread)
int CommandLineRPC(int argc, char *argv[])
void ParseParameters(int argc, const char *const argv[])
bool IsSwitchChar(char c)
void ReadConfigFile(map< string, string > &mapSettingsRet, map< string, vector< string > > &mapMultiSettingsRet)
bool AppInit(int argc, char *argv[])
string FormatFullVersion()
std::string _(const char *psz)
Translation function: Call Translate signal on UI interface, which returns a boost::optional result...
map< string, vector< string > > mapMultiArgs
map< string, string > mapArgs