15 #include <boost/algorithm/string/predicate.hpp>
16 #include <boost/filesystem.hpp>
47 threadGroup->interrupt_all();
48 threadGroup->join_all();
58 boost::thread_group threadGroup;
59 boost::thread* detectShutdownThread = NULL;
69 if (!boost::filesystem::is_directory(
GetDataDir(
false)))
71 fprintf(stderr,
"Error: Specified data directory \"%s\" does not exist.\n",
mapArgs[
"-datadir"].c_str());
77 }
catch(std::exception &e) {
78 fprintf(stderr,
"Error reading configuration file: %s\n", e.what());
83 fprintf(stderr,
"Error: Invalid combination of -regtest and -testnet.\n");
90 std::string strUsage =
_(
"Anoncoin Core Daemon") +
" " +
_(
"version") +
" " +
FormatFullVersion() +
"\n\n" +
92 " anoncoind [options] " +
_(
"Start Anoncoin Core Daemon") +
"\n" +
93 _(
"Usage (deprecated, use anoncoin-cli):") +
"\n" +
94 " anoncoind [options] <command> [params] " +
_(
"Send command to Anoncoin Core") +
"\n" +
95 " anoncoind [options] help " +
_(
"List commands") +
"\n" +
96 " anoncoind [options] help <command> " +
_(
"Get help for a command") +
"\n";
101 fprintf(stdout,
"%s", strUsage.c_str());
106 bool fCommandLine =
false;
107 for (
int i = 1; i < argc; i++)
108 if (!
IsSwitchChar(argv[i][0]) && !boost::algorithm::istarts_with(argv[i],
"anoncoin:"))
120 fprintf(stdout,
"Anoncoin server starting\n");
126 fprintf(stderr,
"Error: fork() returned %d errno %d\n", pid, errno);
136 pid_t sid = setsid();
138 fprintf(stderr,
"Error: setsid() returned %d errno %d\n", sid, errno);
146 catch (std::exception& e) {
154 if (detectShutdownThread)
155 detectShutdownThread->interrupt();
157 threadGroup.interrupt_all();
163 if (detectShutdownThread)
165 detectShutdownThread->join();
166 delete detectShutdownThread;
167 detectShutdownThread = NULL;
174 int main(
int argc,
char* argv[])
188 return (fRet ? 0 : 1);
const boost::filesystem::path & GetDataDir(bool fNetSpecific)
std::string HelpMessageCli(bool mainProgram)
Show help message for anoncoin-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.
std::string HelpMessage(HelpMessageMode hmm)
int main(int argc, char *argv[])
bool AppInit(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 anoncoin.
void PrintExceptionContinue(std::exception *pex, const char *pszThread)
int CommandLineRPC(int argc, char *argv[])
void ParseParameters(int argc, const char *const argv[])
std::string FormatFullVersion()
bool IsSwitchChar(char c)
void ReadConfigFile(map< string, string > &mapSettingsRet, map< string, vector< string > > &mapMultiSettingsRet)
std::string _(const char *psz)
Translation function: Call Translate signal on UI interface, which returns a boost::optional result...
void DetectShutdownThread(boost::thread_group *threadGroup)
map< string, vector< string > > mapMultiArgs
map< string, string > mapArgs