I just started using POCO and it's really amazing. But unfortunately there's something, which does not fit in the flexibility, which POCO offers mostly.
On Linux within the Utils::ServerApplication class implementation the --daemon flag is hardcoded. As I want to achieve the exact opposite of which is possible right now - I need my application to start in daemon mode by default, only when specifing a --nodaemon flag it should not fork - I attached a possible patch doing this. I don't know, if this is the preferred way doing this, but I hope someone could have a look on it. By default the --daemon option behaviour will persist as far as app.daemonOptionCheck(false) won't be called within main(...).
regards,
Stefan
Edit - as far as I see, there's no chance attaching a *diff/*txt file as an attachment:
- Code: Select all
diff -rupN poco-1.3.3p1-all/Util/src/ServerApplication.cpp poco-1.3.3p1-all.new/Util/src/ServerApplication.cpp
--- poco-1.3.3p1-all/Util/src/ServerApplication.cpp 2008-10-09 18:14:02.000000000 +0200
+++ poco-1.3.3p1-all.new/Util/src/ServerApplication.cpp 2010-01-22 06:20:19.000000000 +0100
@@ -82,6 +82,10 @@ ServerApplication::ServerApplication()
_action = SRV_RUN;
std::memset(&_serviceStatus, 0, sizeof(_serviceStatus));
#endif
+
+#if defined(POCO_OS_FAMILY_WINDOWS)
+ _daemonOptionCheck = true;
+#endif
}
@@ -442,14 +446,27 @@ int ServerApplication::run(int argc, cha
return rc;
}
+void daemonOptionCheck(bool check)
+{
+ _daemonOptionCheck = check;
+}
bool ServerApplication::isDaemon(int argc, char** argv)
{
+
+ if (!_daemonOptionCheck)
+ {
+ return false;
+ {
+
std::string option("--daemon");
for (int i = 1; i < argc; ++i)
{
if (option == argv[i])
+ {
+ config().setBool("application.runAsDaemon", true);
return true;
+ }
}
return false;
}
@@ -475,8 +492,11 @@ void ServerApplication::defineOptions(Op
{
Application::defineOptions(options);
- options.addOption(
- Option("daemon", "", "run application as a daemon")
- .required(false)
- .repeatable(false));
+ if (!_daemonOptionCheck)
+ {
+ options.addOption(
+ Option("daemon", "", "run application as a daemon")
+ .required(false)
+ .repeatable(false));
+ }
}





