Merge pull request #3449

8b9adca Allow `-noserver` with bitcoind (Wladimir J. van der Laan)
This commit is contained in:
Wladimir J. van der Laan 2014-01-08 14:35:02 +01:00
commit 549e69a558
No known key found for this signature in database
GPG Key ID: 74810B012346C9A6
5 changed files with 11 additions and 17 deletions

View File

@ -30,6 +30,8 @@
* Use the buttons <code>Namespaces</code>, <code>Classes</code> or <code>Files</code> at the top of the page to start navigating the code. * Use the buttons <code>Namespaces</code>, <code>Classes</code> or <code>Files</code> at the top of the page to start navigating the code.
*/ */
static bool fDaemon;
void DetectShutdownThread(boost::thread_group* threadGroup) void DetectShutdownThread(boost::thread_group* threadGroup)
{ {
bool fShutdown = ShutdownRequested(); bool fShutdown = ShutdownRequested();
@ -108,6 +110,8 @@ bool AppInit(int argc, char* argv[])
fDaemon = GetBoolArg("-daemon", false); fDaemon = GetBoolArg("-daemon", false);
if (fDaemon) if (fDaemon)
{ {
fprintf(stdout, "Bitcoin server starting\n");
// Daemonize // Daemonize
pid_t pid = fork(); pid_t pid = fork();
if (pid < 0) if (pid < 0)
@ -127,9 +131,10 @@ bool AppInit(int argc, char* argv[])
fprintf(stderr, "Error: setsid() returned %d errno %d\n", sid, errno); fprintf(stderr, "Error: setsid() returned %d errno %d\n", sid, errno);
} }
#endif #endif
SoftSetBoolArg("-server", true);
detectShutdownThread = new boost::thread(boost::bind(&DetectShutdownThread, &threadGroup)); detectShutdownThread = new boost::thread(boost::bind(&DetectShutdownThread, &threadGroup));
fRet = AppInit2(threadGroup, true); fRet = AppInit2(threadGroup);
} }
catch (std::exception& e) { catch (std::exception& e) {
PrintExceptionContinue(&e, "AppInit()"); PrintExceptionContinue(&e, "AppInit()");

View File

@ -242,10 +242,7 @@ std::string HelpMessage(HelpMessageMode hmm)
strUsage += " -printtoconsole " + _("Send trace/debug info to console instead of debug.log file") + "\n"; strUsage += " -printtoconsole " + _("Send trace/debug info to console instead of debug.log file") + "\n";
strUsage += " -regtest " + _("Enter regression test mode, which uses a special chain in which blocks can be solved instantly.") + "\n"; strUsage += " -regtest " + _("Enter regression test mode, which uses a special chain in which blocks can be solved instantly.") + "\n";
strUsage += " " + _("This is intended for regression testing tools and app development.") + "\n"; strUsage += " " + _("This is intended for regression testing tools and app development.") + "\n";
if (hmm == HMM_BITCOIN_QT)
{
strUsage += " -server " + _("Accept command line and JSON-RPC commands") + "\n"; strUsage += " -server " + _("Accept command line and JSON-RPC commands") + "\n";
}
if (hmm == HMM_BITCOIND) if (hmm == HMM_BITCOIND)
{ {
@ -356,7 +353,7 @@ void ThreadImport(std::vector<boost::filesystem::path> vImportFiles)
/** Initialize bitcoin. /** Initialize bitcoin.
* @pre Parameters should be parsed and config file should be read. * @pre Parameters should be parsed and config file should be read.
*/ */
bool AppInit2(boost::thread_group& threadGroup, bool fForceServer) bool AppInit2(boost::thread_group& threadGroup)
{ {
// ********************************************************* Step 1: setup // ********************************************************* Step 1: setup
#ifdef _MSC_VER #ifdef _MSC_VER
@ -483,11 +480,7 @@ bool AppInit2(boost::thread_group& threadGroup, bool fForceServer)
else if (nScriptCheckThreads > MAX_SCRIPTCHECK_THREADS) else if (nScriptCheckThreads > MAX_SCRIPTCHECK_THREADS)
nScriptCheckThreads = MAX_SCRIPTCHECK_THREADS; nScriptCheckThreads = MAX_SCRIPTCHECK_THREADS;
if (fDaemon || fForceServer)
fServer = true;
else
fServer = GetBoolArg("-server", false); fServer = GetBoolArg("-server", false);
fPrintToConsole = GetBoolArg("-printtoconsole", false); fPrintToConsole = GetBoolArg("-printtoconsole", false);
fLogTimestamps = GetBoolArg("-logtimestamps", true); fLogTimestamps = GetBoolArg("-logtimestamps", true);
#ifdef ENABLE_WALLET #ifdef ENABLE_WALLET
@ -569,9 +562,6 @@ bool AppInit2(boost::thread_group& threadGroup, bool fForceServer)
LogPrintf("Using at most %i connections (%i file descriptors available)\n", nMaxConnections, nFD); LogPrintf("Using at most %i connections (%i file descriptors available)\n", nMaxConnections, nFD);
std::ostringstream strErrors; std::ostringstream strErrors;
if (fDaemon)
fprintf(stdout, "Bitcoin server starting\n");
if (nScriptCheckThreads) { if (nScriptCheckThreads) {
LogPrintf("Using %u threads for script verification\n", nScriptCheckThreads); LogPrintf("Using %u threads for script verification\n", nScriptCheckThreads);
for (int i=0; i<nScriptCheckThreads-1; i++) for (int i=0; i<nScriptCheckThreads-1; i++)

View File

@ -20,7 +20,7 @@ extern CWallet* pwalletMain;
void StartShutdown(); void StartShutdown();
bool ShutdownRequested(); bool ShutdownRequested();
void Shutdown(); void Shutdown();
bool AppInit2(boost::thread_group& threadGroup, bool fForceServer); bool AppInit2(boost::thread_group& threadGroup);
/* The help message mode determines what help message to show */ /* The help message mode determines what help message to show */
enum HelpMessageMode enum HelpMessageMode

View File

@ -289,7 +289,7 @@ int main(int argc, char *argv[])
QObject::connect(pollShutdownTimer, SIGNAL(timeout()), guiref, SLOT(detectShutdown())); QObject::connect(pollShutdownTimer, SIGNAL(timeout()), guiref, SLOT(detectShutdown()));
pollShutdownTimer->start(200); pollShutdownTimer->start(200);
if(AppInit2(threadGroup, false)) if(AppInit2(threadGroup))
{ {
{ {
// Put this in a block, so that the Model objects are cleaned up before // Put this in a block, so that the Model objects are cleaned up before

View File

@ -121,7 +121,6 @@ extern std::map<std::string, std::vector<std::string> > mapMultiArgs;
extern bool fDebug; extern bool fDebug;
extern bool fPrintToConsole; extern bool fPrintToConsole;
extern bool fPrintToDebugLog; extern bool fPrintToDebugLog;
extern bool fDaemon;
extern bool fServer; extern bool fServer;
extern std::string strMiscWarning; extern std::string strMiscWarning;
extern bool fNoListen; extern bool fNoListen;