mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
Fix 'Restart' RPC command (#894)
This commit is contained in:
@@ -18,6 +18,7 @@ QByteArray command_exec(QString /*cmd*/, QByteArray /*data*/)
|
||||
#include <utils/Logger.h>
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QProcess>
|
||||
#include <QStringList>
|
||||
|
||||
#include <unistd.h>
|
||||
@@ -31,26 +32,20 @@ namespace Process {
|
||||
void restartHyperion(bool asNewProcess)
|
||||
{
|
||||
Logger* log = Logger::getInstance("Process");
|
||||
Info(log, "Restarting hyperion ...");
|
||||
|
||||
std::cout << std::endl
|
||||
<< " *******************************************" << std::endl
|
||||
<< " * hyperion will restart now *" << std::endl
|
||||
<< " *******************************************" << std::endl << std::endl;
|
||||
|
||||
auto arguments = QCoreApplication::arguments();
|
||||
if (!arguments.contains("--wait-hyperion"))
|
||||
arguments << "--wait-hyperion";
|
||||
|
||||
QStringList qargs = QCoreApplication::arguments();
|
||||
int size = qargs.size();
|
||||
char *args[size+1];
|
||||
args[size] = nullptr;
|
||||
for(int i=0; i<size; i++)
|
||||
{
|
||||
int str_size = qargs[i].toLocal8Bit().size();
|
||||
args[i] = new char[str_size+1];
|
||||
strncpy(args[i], qargs[i].toLocal8Bit().constData(),str_size);
|
||||
args[i][str_size] = '\0';
|
||||
}
|
||||
QProcess::startDetached(QCoreApplication::applicationFilePath(), arguments);
|
||||
|
||||
execv(args[0],args);
|
||||
Error(log, "error while restarting hyperion");
|
||||
QCoreApplication::quit();
|
||||
}
|
||||
|
||||
QByteArray command_exec(QString cmd, QByteArray data)
|
||||
|
Reference in New Issue
Block a user