#include #include #include #include #include "mainclass.h" void printUsage() { qDebug()<<"Usage: netsould"; qDebug()<<"\t-h, --help \t\t print this help."; qDebug()<<"\t-p, --pid file \t\t indicate the file path to write de pid. The pid will be written when the daemon is connected to the netsoul server, and a blank file when disconnected."; } int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); MainClass m; for(int i = 1; i < qApp->argc(); ++i) { QString c = qApp->arguments().at(i); if(c == "-p" || c == "--pid") { if(qApp->argc() > i + 1) m.setPidFile(qApp->arguments().at(++i)); else { printUsage(); return 1; } } else { printUsage(); return 1; } } while(!m.start()) { qDebug()<<"[Error] Failed to start. Trying again in 5 seconds..."; sleep(5); } qDebug()<<"[Info ] Daemon started"; return a.exec(); }