mirror of
https://github.com/QuasarApp/Snake.git
synced 2025-04-28 18:54:40 +00:00
68 lines
2.0 KiB
C++
68 lines
2.0 KiB
C++
#include "serverutils.h"
|
|
#include <QtDebug>
|
|
#include <quasarapp.h>
|
|
#include <unistd.h>
|
|
|
|
ServerUtils::ServerUtils() {
|
|
|
|
}
|
|
|
|
void ServerUtils::helpDaemon() {
|
|
|
|
qInfo() << "";
|
|
qInfo() << "Usage: SnakeServer-daemon.sh <[params]> ";
|
|
qInfo() << "";
|
|
qInfo() << "Options:";
|
|
qInfo() << " help / h : show help.";
|
|
qInfo() << " daemon / d : start like daemon.";
|
|
qInfo() << " -port (port) : start with custom port.";
|
|
qInfo() << " -address (address) : start with custom address.";
|
|
qInfo() << " -db (path/to/db.file) : start with custom db";
|
|
|
|
qInfo() << " verbose : show debug log";
|
|
|
|
qInfo() << "";
|
|
}
|
|
|
|
void ServerUtils::helpClient() {
|
|
|
|
qInfo() << "";
|
|
qInfo() << "Usage: Terminal.sh <[params]> ";
|
|
qInfo() << "";
|
|
qInfo() << "Options:";
|
|
qInfo() << " help / h : show help.";
|
|
qInfo() << " ping : debug commnad";
|
|
qInfo() << " state : show information about deamon";
|
|
qInfo() << " stop : stop server deamon";
|
|
qInfo() << " -ban (address) : ban user with address";
|
|
qInfo() << " -unban (address) : unban user with address";
|
|
qInfo() << " -restart (address:port) : restarrt server deamon with new address and port";
|
|
qInfo() << " -start (address:port) : start server deamon with custom address";
|
|
qInfo() << " start : start server deamon with default address";
|
|
|
|
qInfo() << " verbose : show debug log";
|
|
|
|
qInfo() << "";
|
|
}
|
|
|
|
bool ServerUtils::runDaemon() {
|
|
if (QuasarAppUtils::Params::isEndable("daemon") ||
|
|
QuasarAppUtils::Params::isEndable("d")) {
|
|
|
|
int pid = fork();
|
|
if (pid != 0) {
|
|
return true;
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
bool ServerUtils::parseParams(int argc, char *argv[]) {
|
|
if ( !QuasarAppUtils::Params::parseParams(argc, const_cast<const char**>(argv))) {
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|