feat: Remove daemon / no-daemon option

This commit is contained in:
sithlord48
2025-09-23 10:25:42 -04:00
committed by Nick Bolton
parent fd7950bc04
commit 03e014c753
12 changed files with 7 additions and 93 deletions

View File

@ -153,11 +153,9 @@ constexpr static auto s_helpCommonArgs = //
// system args (windows/unix)
#if SYSAPI_UNIX
// unix daemon mode args
constexpr static auto s_helpSysArgs = " [--daemon|--no-daemon]";
constexpr static auto s_helpSysInfo = //
" -f, --no-daemon run in the foreground.\n"
"* --daemon run as a daemon.\n";
// unix has no system args
constexpr static auto s_helpSysArgs = "";
constexpr static auto s_helpSysInfo = "";
#elif SYSAPI_WIN32

View File

@ -129,12 +129,6 @@ bool ArgParser::parseGenericArgs(int argc, const char *const *argv, int &i) cons
argsBase().m_logFilter = argv[++i];
} else if (isArg(i, argc, argv, "-l", "--log", 1)) {
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)) {
// save screen name
argsBase().m_name = argv[++i];
@ -339,19 +333,5 @@ void ArgParser::updateCommonArgs(const char *const *argv) 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;
}

View File

@ -32,9 +32,6 @@ public:
/// @brief Stores what type of object this is
ClassType m_classType = ClassType::Base;
/// @brief Should run as a daemon
bool m_daemon = true;
/// @brief Should the app restart automatically
bool m_restartable = true;

View File

@ -109,7 +109,7 @@ void ClientApp::help()
#ifdef WINAPI_XWINDOWS
<< " [--display <display>]"
#endif
<< s_helpSysArgs << s_helpCommonArgs << " <server-address>"
<< s_helpCommonArgs << " <server-address>"
<< "\n\n"
<< "Connect to a " << kAppName << " mouse/keyboard sharing server.\n"
<< "\n"
@ -314,14 +314,6 @@ void ClientApp::closeClient(Client *client)
delete client;
}
int ClientApp::foregroundStartup(int argc, char **argv)
{
initApp(argc, argv);
// never daemonize
return mainLoop();
}
bool ClientApp::startClient()
{
double retryTime;
@ -413,13 +405,7 @@ static int daemonMainLoopStatic(int argc, const char **argv)
int ClientApp::standardStartup(int argc, char **argv)
{
initApp(argc, argv);
// daemonize if requested
if (args().m_daemon) {
return ARCH->daemonize(daemonName(), &daemonMainLoopStatic);
} else {
return mainLoop();
}
return mainLoop();
}
int ClientApp::runInner(int argc, char **argv, StartupFunc startup)

View File

@ -43,7 +43,6 @@ public:
{
return false;
}
int foregroundStartup(int argc, char **argv) override;
int standardStartup(int argc, char **argv) override;
int runInner(int argc, char **argv, StartupFunc startup) override;
deskflow::Screen *createScreen() override;

View File

@ -30,7 +30,6 @@ public:
virtual int mainLoop() = 0;
virtual void initApp(int argc, const char **argv) = 0;
virtual const char *daemonName() const = 0;
virtual int foregroundStartup(int argc, char **argv) = 0;
virtual deskflow::Screen *createScreen() = 0;
virtual IEventQueue *getEvents() const = 0;
};

View File

@ -678,20 +678,6 @@ int daemonMainLoopStatic(int argc, const char **argv)
int ServerApp::standardStartup(int argc, char **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();
}

View File

@ -65,7 +65,6 @@ public:
int mainLoop() override;
int runInner(int argc, char **argv, StartupFunc startup) override;
int standardStartup(int argc, char **argv) override;
int foregroundStartup(int argc, char **argv) override;
void startNode() override;
//

View File

@ -100,7 +100,7 @@ static int daemonNTStartupStatic(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)
@ -120,7 +120,6 @@ int AppUtilWindows::run(int argc, char **argv)
startup = &daemonNTStartupStatic;
} else {
startup = &foregroundStartupStatic;
app().argsBase().m_daemon = false;
}
return app().runInner(argc, argv, startup);

View File

@ -461,8 +461,7 @@ void CoreProcess::cleanup()
bool CoreProcess::addGenericArgs(QStringList &args) const
{
args << "-f"
<< "--debug" << Settings::logLevelText();
args << "--debug" << Settings::logLevelText();
args << "--name" << Settings::value(Settings::Core::ScreenName).toString();

View File

@ -196,7 +196,6 @@ void ArgParserTests::server_unexpectedParam()
void ArgParserTests::serverArgs()
{
deskflow::ServerArgs args;
args.m_daemon = false;
char const *argv[] = {"deskflow", "--help", "--res-w", "888"};
QVERIFY(m_parser.parseServerArgs(args, sizeof(argv) / sizeof(argv[0]), argv));
@ -206,7 +205,6 @@ void ArgParserTests::serverArgs()
void ArgParserTests::clientArgs()
{
deskflow::ClientArgs args;
args.m_daemon = false;
char const *argv[] = {kAppId, "--help", "--res-w", "888", "127.0.0.1"};
QVERIFY(m_parser.parseClientArgs(args, sizeof(argv) / sizeof(argv[0]), argv));
@ -339,30 +337,6 @@ void ArgParserTests::generic_logFileWithSpace()
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()
{
int i = 1;

View File

@ -37,8 +37,6 @@ private Q_SLOTS:
void generic_logLevel();
void generic_logFile();
void generic_logFileWithSpace();
void generic_foreground();
void generic_daemon();
void generic_name();
void generic_noRestart();
void generic_restart();