From: SomeDude Date: Mon, 30 Jun 2008 16:01:00 +0000 (+0200) Subject: version 0.3.3 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=3751f10f7127ae0905aa0b52dc6de1c782a38c99;p=fms.git version 0.3.3 --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 03af9bd..1ab671d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -210,3 +210,8 @@ IF(DO_CHARSET_CONVERSION) ENDIF(WIN32) ENDIF(ICONV_LIBRARY) ENDIF(DO_CHARSET_CONVERSION) + +# FreeBSD won't find Poco include files without this +IF(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") + INCLUDE_DIRECTORIES(AFTER /usr/local/include) +ENDIF(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") diff --git a/include/fmsapp.h b/include/fmsapp.h index a816d9a..dab56e1 100644 --- a/include/fmsapp.h +++ b/include/fmsapp.h @@ -23,8 +23,10 @@ private: void handleHelp(const std::string &name, const std::string &value); void displayHelp(); + void handleLogOption(const std::string &name, const std::string &value); bool m_displayhelp; + std::string m_logtype; ThreadedExecutor m_threads; diff --git a/include/global.h b/include/global.h index d6ba0df..bd580af 100644 --- a/include/global.h +++ b/include/global.h @@ -7,7 +7,7 @@ #define VERSION_MAJOR "0" #define VERSION_MINOR "3" -#define VERSION_RELEASE "2" +#define VERSION_RELEASE "3" #define FMS_VERSION VERSION_MAJOR"."VERSION_MINOR"."VERSION_RELEASE typedef Poco::ScopedLock Guard; diff --git a/readme.txt b/readme.txt index 0fb3777..77ca276 100644 --- a/readme.txt +++ b/readme.txt @@ -1,7 +1,7 @@ COMPILING --------- -Compiling FMS requires CMake, Poco and iconv if you want to do charset -conversion. Other required libraries are bundled with FMS. +Compiling FMS requires CMake, Poco ( version >=1.2.9 ) and iconv if you want to +do charset conversion. Other required libraries are bundled with FMS. To compile, run these commands from the source directory: cmake -D I_HAVE_READ_THE_README=ON . @@ -30,13 +30,14 @@ sure the user that runs FMS has read/write access to this directory. RUNNING ------- -You may run FMS in console mode by running the binary directly. If you are -running *nix and would like to run as a daemon, use the --daemon argument. On -Windows, /registerService will install FMS as a service, and /unregisterService -will uninstall the service. Use the /displayName=name argument when installing -the service to set the service name to whatever you want. You will need to -manually start the service unless you change the startup type in the service -properties. +You may run FMS in console mode by running the binary directly. You can view +available command line options by typing /help on Windows and --help on other +platforms. If you are running *nix and would like to run as a daemon, use the +--daemon argument. On Windows, /registerService will install FMS as a service, +and /unregisterService will uninstall the service. Use the /displayName=name +argument when installing the service to set the service name to whatever you +want. You will need to manually start the service unless you change the +startup type in the service properties. EXITING ------- diff --git a/src/fmsapp.cpp b/src/fmsapp.cpp index 810bd5f..04562fc 100644 --- a/src/fmsapp.cpp +++ b/src/fmsapp.cpp @@ -12,6 +12,7 @@ #include #include +#include #include #include #include @@ -43,7 +44,7 @@ public: } }; -FMSApp::FMSApp():m_displayhelp(false) +FMSApp::FMSApp():m_displayhelp(false),m_logtype("file") { } @@ -54,6 +55,7 @@ void FMSApp::defineOptions(Poco::Util::OptionSet &options) // add command line options here options.addOption(Poco::Util::Option("help","?","display help for command line arguments",false).repeatable(false).callback(Poco::Util::OptionCallback(this,&FMSApp::handleHelp))); + options.addOption(Poco::Util::Option("log","l","select type of log output (file|stdout|stderr)",false,"type",true).repeatable(false).callback(Poco::Util::OptionCallback(this,&FMSApp::handleLogOption))); } void FMSApp::displayHelp() @@ -72,6 +74,14 @@ void FMSApp::handleHelp(const std::string &name, const std::string &value) stopOptionsProcessing(); } +void FMSApp::handleLogOption(const std::string &name, const std::string &value) +{ + if(value=="file" || value=="stdout" || value=="stderr") + { + m_logtype=value; + } +} + void FMSApp::initialize(Poco::Util::Application &self) { ServerApplication::initialize(self); @@ -96,13 +106,30 @@ void FMSApp::initializeLogger() } Poco::AutoPtr formatter=new Poco::FormattingChannel(new Poco::PatternFormatter("%Y-%m-%d %H:%M:%S | %p | %t")); - Poco::AutoPtr fc=new Poco::FileChannel("fms.log"); - fc->setProperty("rotation","daily"); // rotate log file daily - fc->setProperty("times","utc"); // utc date/times for log entries - fc->setProperty("archive","timestamp"); // add timestamp to old logs - fc->setProperty("purgeCount","30"); // purge old logs after 30 logs have accumulated - fc->setProperty("compress","true"); // gz compress old log files - formatter->setChannel(fc); + + if(m_logtype=="file") + { + Poco::AutoPtr fc=new Poco::FileChannel("fms.log"); + fc->setProperty("rotation","daily"); // rotate log file daily + fc->setProperty("times","utc"); // utc date/times for log entries + fc->setProperty("archive","timestamp"); // add timestamp to old logs + fc->setProperty("purgeCount","30"); // purge old logs after 30 logs have accumulated + fc->setProperty("compress","true"); // gz compress old log files + formatter->setChannel(fc); + } + else + { + if(m_logtype=="stdout") + { + Poco::AutoPtr cc=new Poco::ConsoleChannel(std::cout); + formatter->setChannel(cc); + } + else + { + Poco::AutoPtr cc=new Poco::ConsoleChannel(std::cerr); + formatter->setChannel(cc); + } + } setLogger(Poco::Logger::create("logfile",formatter,initiallevel)); } @@ -110,12 +137,22 @@ void FMSApp::initializeLogger() int FMSApp::main(const std::vector &args) { + // running as a daemon would reset the working directory to / before calling main + // so we need to set the working directory again + // set working directory to program directory + int rval=chdir(config().getString("application.dir").c_str()); + if(m_displayhelp==false) { logger().information("FMS startup v"FMS_VERSION); StartThreads(); + if(isInteractive()==true) + { + std::cout << "FMS has been started." << std::endl << std::endl; + } + waitForTerminationRequest(); m_threads.Cancel(); diff --git a/src/http/fmshttprequesthandlerfactory.cpp b/src/http/fmshttprequesthandlerfactory.cpp index 819b02b..46f31a2 100644 --- a/src/http/fmshttprequesthandlerfactory.cpp +++ b/src/http/fmshttprequesthandlerfactory.cpp @@ -89,5 +89,9 @@ Poco::Net::HTTPRequestHandler *FMSHTTPRequestHandlerFactory::createRequestHandle } } } + else + { + m_log->debug("FMSHTTPRequestHandlerFactory::createRequestHandler host denied access "+request.clientAddress().host().toString()); + } return 0; }