feat: Remove daemon / no-daemon option
This commit is contained in:
parent
fd7950bc04
commit
03e014c753
12 changed files with 7 additions and 93 deletions
|
|
@ -153,11 +153,9 @@ constexpr static auto s_helpCommonArgs = //
|
||||||
// system args (windows/unix)
|
// system args (windows/unix)
|
||||||
#if SYSAPI_UNIX
|
#if SYSAPI_UNIX
|
||||||
|
|
||||||
// unix daemon mode args
|
// unix has no system args
|
||||||
constexpr static auto s_helpSysArgs = " [--daemon|--no-daemon]";
|
constexpr static auto s_helpSysArgs = "";
|
||||||
constexpr static auto s_helpSysInfo = //
|
constexpr static auto s_helpSysInfo = "";
|
||||||
" -f, --no-daemon run in the foreground.\n"
|
|
||||||
"* --daemon run as a daemon.\n";
|
|
||||||
|
|
||||||
#elif SYSAPI_WIN32
|
#elif SYSAPI_WIN32
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -129,12 +129,6 @@ bool ArgParser::parseGenericArgs(int argc, const char *const *argv, int &i) cons
|
||||||
argsBase().m_logFilter = argv[++i];
|
argsBase().m_logFilter = argv[++i];
|
||||||
} else if (isArg(i, argc, argv, "-l", "--log", 1)) {
|
} else if (isArg(i, argc, argv, "-l", "--log", 1)) {
|
||||||
argsBase().m_logFile = argv[++i];
|
argsBase().m_logFile = argv[++i];
|
||||||
} else if (isArg(i, argc, argv, "-f", "--no-daemon")) {
|
|
||||||
// not a daemon
|
|
||||||
argsBase().m_daemon = false;
|
|
||||||
} else if (isArg(i, argc, argv, nullptr, "--daemon")) {
|
|
||||||
// daemonize
|
|
||||||
argsBase().m_daemon = true;
|
|
||||||
} else if (isArg(i, argc, argv, "-n", "--name", 1)) {
|
} else if (isArg(i, argc, argv, "-n", "--name", 1)) {
|
||||||
// save screen name
|
// save screen name
|
||||||
argsBase().m_name = argv[++i];
|
argsBase().m_name = argv[++i];
|
||||||
|
|
@ -339,19 +333,5 @@ void ArgParser::updateCommonArgs(const char *const *argv) const
|
||||||
|
|
||||||
bool ArgParser::checkUnexpectedArgs() const
|
bool ArgParser::checkUnexpectedArgs() const
|
||||||
{
|
{
|
||||||
#if SYSAPI_WIN32
|
|
||||||
// suggest that user installs as a windows service. when launched as
|
|
||||||
// service, process should automatically detect that it should run in
|
|
||||||
// daemon mode.
|
|
||||||
if (argsBase().m_daemon) {
|
|
||||||
LOG(
|
|
||||||
(CLOG_ERR "the --daemon argument is not supported on windows. "
|
|
||||||
"instead, install %s as a service (--service install)",
|
|
||||||
argsBase().m_pname)
|
|
||||||
);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,9 +32,6 @@ public:
|
||||||
/// @brief Stores what type of object this is
|
/// @brief Stores what type of object this is
|
||||||
ClassType m_classType = ClassType::Base;
|
ClassType m_classType = ClassType::Base;
|
||||||
|
|
||||||
/// @brief Should run as a daemon
|
|
||||||
bool m_daemon = true;
|
|
||||||
|
|
||||||
/// @brief Should the app restart automatically
|
/// @brief Should the app restart automatically
|
||||||
bool m_restartable = true;
|
bool m_restartable = true;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -109,7 +109,7 @@ void ClientApp::help()
|
||||||
#ifdef WINAPI_XWINDOWS
|
#ifdef WINAPI_XWINDOWS
|
||||||
<< " [--display <display>]"
|
<< " [--display <display>]"
|
||||||
#endif
|
#endif
|
||||||
<< s_helpSysArgs << s_helpCommonArgs << " <server-address>"
|
<< s_helpCommonArgs << " <server-address>"
|
||||||
<< "\n\n"
|
<< "\n\n"
|
||||||
<< "Connect to a " << kAppName << " mouse/keyboard sharing server.\n"
|
<< "Connect to a " << kAppName << " mouse/keyboard sharing server.\n"
|
||||||
<< "\n"
|
<< "\n"
|
||||||
|
|
@ -314,14 +314,6 @@ void ClientApp::closeClient(Client *client)
|
||||||
delete client;
|
delete client;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ClientApp::foregroundStartup(int argc, char **argv)
|
|
||||||
{
|
|
||||||
initApp(argc, argv);
|
|
||||||
|
|
||||||
// never daemonize
|
|
||||||
return mainLoop();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ClientApp::startClient()
|
bool ClientApp::startClient()
|
||||||
{
|
{
|
||||||
double retryTime;
|
double retryTime;
|
||||||
|
|
@ -413,13 +405,7 @@ static int daemonMainLoopStatic(int argc, const char **argv)
|
||||||
int ClientApp::standardStartup(int argc, char **argv)
|
int ClientApp::standardStartup(int argc, char **argv)
|
||||||
{
|
{
|
||||||
initApp(argc, argv);
|
initApp(argc, argv);
|
||||||
|
return mainLoop();
|
||||||
// daemonize if requested
|
|
||||||
if (args().m_daemon) {
|
|
||||||
return ARCH->daemonize(daemonName(), &daemonMainLoopStatic);
|
|
||||||
} else {
|
|
||||||
return mainLoop();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int ClientApp::runInner(int argc, char **argv, StartupFunc startup)
|
int ClientApp::runInner(int argc, char **argv, StartupFunc startup)
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,6 @@ public:
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
int foregroundStartup(int argc, char **argv) override;
|
|
||||||
int standardStartup(int argc, char **argv) override;
|
int standardStartup(int argc, char **argv) override;
|
||||||
int runInner(int argc, char **argv, StartupFunc startup) override;
|
int runInner(int argc, char **argv, StartupFunc startup) override;
|
||||||
deskflow::Screen *createScreen() override;
|
deskflow::Screen *createScreen() override;
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,6 @@ public:
|
||||||
virtual int mainLoop() = 0;
|
virtual int mainLoop() = 0;
|
||||||
virtual void initApp(int argc, const char **argv) = 0;
|
virtual void initApp(int argc, const char **argv) = 0;
|
||||||
virtual const char *daemonName() const = 0;
|
virtual const char *daemonName() const = 0;
|
||||||
virtual int foregroundStartup(int argc, char **argv) = 0;
|
|
||||||
virtual deskflow::Screen *createScreen() = 0;
|
virtual deskflow::Screen *createScreen() = 0;
|
||||||
virtual IEventQueue *getEvents() const = 0;
|
virtual IEventQueue *getEvents() const = 0;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -678,20 +678,6 @@ int daemonMainLoopStatic(int argc, const char **argv)
|
||||||
int ServerApp::standardStartup(int argc, char **argv)
|
int ServerApp::standardStartup(int argc, char **argv)
|
||||||
{
|
{
|
||||||
initApp(argc, argv);
|
initApp(argc, argv);
|
||||||
|
|
||||||
// daemonize if requested
|
|
||||||
if (args().m_daemon) {
|
|
||||||
return ARCH->daemonize(daemonName(), daemonMainLoopStatic);
|
|
||||||
} else {
|
|
||||||
return mainLoop();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int ServerApp::foregroundStartup(int argc, char **argv)
|
|
||||||
{
|
|
||||||
initApp(argc, argv);
|
|
||||||
|
|
||||||
// never daemonize
|
|
||||||
return mainLoop();
|
return mainLoop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,6 @@ public:
|
||||||
int mainLoop() override;
|
int mainLoop() override;
|
||||||
int runInner(int argc, char **argv, StartupFunc startup) override;
|
int runInner(int argc, char **argv, StartupFunc startup) override;
|
||||||
int standardStartup(int argc, char **argv) override;
|
int standardStartup(int argc, char **argv) override;
|
||||||
int foregroundStartup(int argc, char **argv) override;
|
|
||||||
void startNode() override;
|
void startNode() override;
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
|
||||||
|
|
@ -100,7 +100,7 @@ static int daemonNTStartupStatic(int argc, char **argv)
|
||||||
|
|
||||||
static int foregroundStartupStatic(int argc, char **argv)
|
static int foregroundStartupStatic(int argc, char **argv)
|
||||||
{
|
{
|
||||||
return AppUtil::instance().app().foregroundStartup(argc, argv);
|
return AppUtil::instance().app().standardStartup(argc, argv);
|
||||||
}
|
}
|
||||||
|
|
||||||
int AppUtilWindows::run(int argc, char **argv)
|
int AppUtilWindows::run(int argc, char **argv)
|
||||||
|
|
@ -120,7 +120,6 @@ int AppUtilWindows::run(int argc, char **argv)
|
||||||
startup = &daemonNTStartupStatic;
|
startup = &daemonNTStartupStatic;
|
||||||
} else {
|
} else {
|
||||||
startup = &foregroundStartupStatic;
|
startup = &foregroundStartupStatic;
|
||||||
app().argsBase().m_daemon = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return app().runInner(argc, argv, startup);
|
return app().runInner(argc, argv, startup);
|
||||||
|
|
|
||||||
|
|
@ -461,8 +461,7 @@ void CoreProcess::cleanup()
|
||||||
|
|
||||||
bool CoreProcess::addGenericArgs(QStringList &args) const
|
bool CoreProcess::addGenericArgs(QStringList &args) const
|
||||||
{
|
{
|
||||||
args << "-f"
|
args << "--debug" << Settings::logLevelText();
|
||||||
<< "--debug" << Settings::logLevelText();
|
|
||||||
|
|
||||||
args << "--name" << Settings::value(Settings::Core::ScreenName).toString();
|
args << "--name" << Settings::value(Settings::Core::ScreenName).toString();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -196,7 +196,6 @@ void ArgParserTests::server_unexpectedParam()
|
||||||
void ArgParserTests::serverArgs()
|
void ArgParserTests::serverArgs()
|
||||||
{
|
{
|
||||||
deskflow::ServerArgs args;
|
deskflow::ServerArgs args;
|
||||||
args.m_daemon = false;
|
|
||||||
char const *argv[] = {"deskflow", "--help", "--res-w", "888"};
|
char const *argv[] = {"deskflow", "--help", "--res-w", "888"};
|
||||||
|
|
||||||
QVERIFY(m_parser.parseServerArgs(args, sizeof(argv) / sizeof(argv[0]), argv));
|
QVERIFY(m_parser.parseServerArgs(args, sizeof(argv) / sizeof(argv[0]), argv));
|
||||||
|
|
@ -206,7 +205,6 @@ void ArgParserTests::serverArgs()
|
||||||
void ArgParserTests::clientArgs()
|
void ArgParserTests::clientArgs()
|
||||||
{
|
{
|
||||||
deskflow::ClientArgs args;
|
deskflow::ClientArgs args;
|
||||||
args.m_daemon = false;
|
|
||||||
char const *argv[] = {kAppId, "--help", "--res-w", "888", "127.0.0.1"};
|
char const *argv[] = {kAppId, "--help", "--res-w", "888", "127.0.0.1"};
|
||||||
|
|
||||||
QVERIFY(m_parser.parseClientArgs(args, sizeof(argv) / sizeof(argv[0]), argv));
|
QVERIFY(m_parser.parseClientArgs(args, sizeof(argv) / sizeof(argv[0]), argv));
|
||||||
|
|
@ -339,30 +337,6 @@ void ArgParserTests::generic_logFileWithSpace()
|
||||||
QCOMPARE(i, 2);
|
QCOMPARE(i, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ArgParserTests::generic_foreground()
|
|
||||||
{
|
|
||||||
int i = 1;
|
|
||||||
const int argc = 2;
|
|
||||||
const char *kNoDeamonCmd[argc] = {"stub", "-f"};
|
|
||||||
|
|
||||||
m_parser.parseGenericArgs(argc, kNoDeamonCmd, i);
|
|
||||||
|
|
||||||
QVERIFY(!m_parser.argsBase().m_daemon);
|
|
||||||
QCOMPARE(i, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ArgParserTests::generic_daemon()
|
|
||||||
{
|
|
||||||
int i = 1;
|
|
||||||
const int argc = 2;
|
|
||||||
const char *kDeamonCmd[argc] = {"stub", "--daemon"};
|
|
||||||
|
|
||||||
m_parser.parseGenericArgs(argc, kDeamonCmd, i);
|
|
||||||
|
|
||||||
QVERIFY(m_parser.argsBase().m_daemon);
|
|
||||||
QCOMPARE(i, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ArgParserTests::generic_name()
|
void ArgParserTests::generic_name()
|
||||||
{
|
{
|
||||||
int i = 1;
|
int i = 1;
|
||||||
|
|
|
||||||
|
|
@ -37,8 +37,6 @@ private Q_SLOTS:
|
||||||
void generic_logLevel();
|
void generic_logLevel();
|
||||||
void generic_logFile();
|
void generic_logFile();
|
||||||
void generic_logFileWithSpace();
|
void generic_logFileWithSpace();
|
||||||
void generic_foreground();
|
|
||||||
void generic_daemon();
|
|
||||||
void generic_name();
|
void generic_name();
|
||||||
void generic_noRestart();
|
void generic_noRestart();
|
||||||
void generic_restart();
|
void generic_restart();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue