COMPILING\r
---------\r
-Compiling FMS requires CMake, Poco and iconv if you want to do charset\r
-conversion. Other required libraries are bundled with FMS.\r
+Compiling FMS requires CMake, Poco ( version >=1.2.9 ) and iconv if you want to\r
+do charset conversion. Other required libraries are bundled with FMS.\r
\r
To compile, run these commands from the source directory:\r
cmake -D I_HAVE_READ_THE_README=ON .\r
\r
RUNNING\r
-------\r
-You may run FMS in console mode by running the binary directly. If you are\r
-running *nix and would like to run as a daemon, use the --daemon argument. On\r
-Windows, /registerService will install FMS as a service, and /unregisterService\r
-will uninstall the service. Use the /displayName=name argument when installing\r
-the service to set the service name to whatever you want. You will need to\r
-manually start the service unless you change the startup type in the service\r
-properties.\r
+You may run FMS in console mode by running the binary directly. You can view\r
+available command line options by typing /help on Windows and --help on other\r
+platforms. If you are running *nix and would like to run as a daemon, use the \r
+--daemon argument. On Windows, /registerService will install FMS as a service,\r
+and /unregisterService will uninstall the service. Use the /displayName=name\r
+argument when installing the service to set the service name to whatever you\r
+want. You will need to manually start the service unless you change the\r
+startup type in the service properties.\r
\r
EXITING\r
-------\r
\r
#include <Poco/Util/HelpFormatter.h>\r
#include <Poco/FileChannel.h>\r
+#include <Poco/ConsoleChannel.h>\r
#include <Poco/FormattingChannel.h>\r
#include <Poco/PatternFormatter.h>\r
#include <iostream>\r
}\r
};\r
\r
-FMSApp::FMSApp():m_displayhelp(false)\r
+FMSApp::FMSApp():m_displayhelp(false),m_logtype("file")\r
{\r
\r
}\r
\r
// add command line options here\r
options.addOption(Poco::Util::Option("help","?","display help for command line arguments",false).repeatable(false).callback(Poco::Util::OptionCallback<FMSApp>(this,&FMSApp::handleHelp)));\r
+ options.addOption(Poco::Util::Option("log","l","select type of log output (file|stdout|stderr)",false,"type",true).repeatable(false).callback(Poco::Util::OptionCallback<FMSApp>(this,&FMSApp::handleLogOption)));\r
}\r
\r
void FMSApp::displayHelp()\r
stopOptionsProcessing();\r
}\r
\r
+void FMSApp::handleLogOption(const std::string &name, const std::string &value)\r
+{\r
+ if(value=="file" || value=="stdout" || value=="stderr")\r
+ {\r
+ m_logtype=value;\r
+ }\r
+}\r
+\r
void FMSApp::initialize(Poco::Util::Application &self)\r
{\r
ServerApplication::initialize(self);\r
}\r
\r
Poco::AutoPtr<Poco::FormattingChannel> formatter=new Poco::FormattingChannel(new Poco::PatternFormatter("%Y-%m-%d %H:%M:%S | %p | %t"));\r
- Poco::AutoPtr<Poco::FileChannel> fc=new Poco::FileChannel("fms.log");\r
- fc->setProperty("rotation","daily"); // rotate log file daily\r
- fc->setProperty("times","utc"); // utc date/times for log entries\r
- fc->setProperty("archive","timestamp"); // add timestamp to old logs\r
- fc->setProperty("purgeCount","30"); // purge old logs after 30 logs have accumulated\r
- fc->setProperty("compress","true"); // gz compress old log files\r
- formatter->setChannel(fc);\r
+ \r
+ if(m_logtype=="file")\r
+ {\r
+ Poco::AutoPtr<Poco::FileChannel> fc=new Poco::FileChannel("fms.log");\r
+ fc->setProperty("rotation","daily"); // rotate log file daily\r
+ fc->setProperty("times","utc"); // utc date/times for log entries\r
+ fc->setProperty("archive","timestamp"); // add timestamp to old logs\r
+ fc->setProperty("purgeCount","30"); // purge old logs after 30 logs have accumulated\r
+ fc->setProperty("compress","true"); // gz compress old log files\r
+ formatter->setChannel(fc);\r
+ }\r
+ else\r
+ {\r
+ if(m_logtype=="stdout")\r
+ {\r
+ Poco::AutoPtr<Poco::ConsoleChannel> cc=new Poco::ConsoleChannel(std::cout);\r
+ formatter->setChannel(cc);\r
+ }\r
+ else\r
+ {\r
+ Poco::AutoPtr<Poco::ConsoleChannel> cc=new Poco::ConsoleChannel(std::cerr);\r
+ formatter->setChannel(cc);\r
+ }\r
+ }\r
\r
setLogger(Poco::Logger::create("logfile",formatter,initiallevel));\r
}\r
int FMSApp::main(const std::vector<std::string> &args)\r
{\r
\r
+ // running as a daemon would reset the working directory to / before calling main\r
+ // so we need to set the working directory again\r
+ // set working directory to program directory\r
+ int rval=chdir(config().getString("application.dir").c_str());\r
+\r
if(m_displayhelp==false)\r
{\r
logger().information("FMS startup v"FMS_VERSION);\r
\r
StartThreads();\r
\r
+ if(isInteractive()==true)\r
+ {\r
+ std::cout << "FMS has been started." << std::endl << std::endl;\r
+ }\r
+\r
waitForTerminationRequest();\r
\r
m_threads.Cancel();\r