DaemonManager: windows support

This commit is contained in:
Jacob Brydolf 2016-11-07 11:55:11 +01:00 committed by Jaquee
parent 5da9f8fbe4
commit 3df9e44849
No known key found for this signature in database
GPG key ID: 384E52B09F45DC39

View file

@ -21,17 +21,33 @@ DaemonManager *DaemonManager::instance()
bool DaemonManager::start() bool DaemonManager::start()
{ {
QString program = QApplication::applicationDirPath() + "/monerod";
qDebug() << "starting monerod " + program; //
QString process;
#ifdef Q_OS_WIN
process = QApplication::applicationDirPath() + "/monerod.exe";
#elif defined(Q_OS_UNIX)
process = QApplication::applicationDirPath() + "/monerod";
#endif
if(process.length() == 0) {
qDebug() << "no daemon binary defined for current platform";
return false;
}
qDebug() << "starting monerod " + process;
// TODO: forward CLI arguments
QStringList arguments; QStringList arguments;
m_daemon = new QProcess(); m_daemon = new QProcess();
// Connect output slots
connect (m_daemon, SIGNAL(readyReadStandardOutput()), this, SLOT(printOutput())); connect (m_daemon, SIGNAL(readyReadStandardOutput()), this, SLOT(printOutput()));
connect (m_daemon, SIGNAL(readyReadStandardError()), this, SLOT(printError())); connect (m_daemon, SIGNAL(readyReadStandardError()), this, SLOT(printError()));
m_daemon->start(program); m_daemon->start(process);
bool started = m_daemon->waitForStarted(); bool started = m_daemon->waitForStarted();
if(!started){ if(!started){
@ -48,8 +64,8 @@ bool DaemonManager::stop()
if(m_daemon){ if(m_daemon){
qDebug() << "stopping daemon"; qDebug() << "stopping daemon";
m_daemon->terminate(); m_daemon->terminate();
// Wait until stopped. Max 30 seconds // Wait until stopped. Max 10 seconds
bool stopped = m_daemon->waitForFinished(30000); bool stopped = m_daemon->waitForFinished(10000);
if(stopped) emit daemonStopped(); if(stopped) emit daemonStopped();
return stopped; return stopped;
} }