X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Ffmsapp.cpp;h=261ea4643c96abe934b2bc8d34e670acb612c155;hb=e662ea47fba8715474851ceebacba400984ee433;hp=318244382475fd013734060e7e85f9eec3d77910;hpb=cd97061e86eeecf5b77dea35f0549e73a50eb200;p=fms.git diff --git a/src/fmsapp.cpp b/src/fmsapp.cpp index 3182443..261ea46 100644 --- a/src/fmsapp.cpp +++ b/src/fmsapp.cpp @@ -17,6 +17,8 @@ #include #include #include +#include +#include #ifdef _WIN32 #include @@ -24,9 +26,17 @@ #include #endif -FMSApp::FMSApp():m_displayhelp(false),m_showoptions(false),m_setoption(false),m_logtype("file") +FMSApp::FMSApp():m_displayhelp(false),m_showoptions(false),m_setoption(false),m_logtype("file"),m_workingdirectory("") { - + // get current working dir so we can go to it later + char wd[1024]; + char *wdptr=NULL; + memset(wd,0,1024); + wdptr=getcwd(wd,1023); + if(wdptr) + { + m_workingdirectory=wdptr; + } } void FMSApp::defineOptions(Poco::Util::OptionSet &options) @@ -90,8 +100,13 @@ void FMSApp::initialize(Poco::Util::Application &self) { ServerApplication::initialize(self); - // set working directory to program directory - int rval=chdir(config().getString("application.dir").c_str()); + // set working directory - fall back on application.dir if working directory isn't set + // if we are runing as a service, then working directory needs to be set to the application directory + if(m_workingdirectory=="" || config().getBool("application.runAsService",false)==true) + { + m_workingdirectory=config().getString("application.dir"); + } + int rval=chdir(m_workingdirectory.c_str()); SetupDB(); SetupDefaultOptions(); @@ -145,10 +160,14 @@ 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()); + int rval=chdir(m_workingdirectory.c_str()); - if(m_displayhelp) + if(VerifyDB()==false) + { + std::cout << "The FMS database failed verification. It is most likely corrupt!" << std::endl; + logger().fatal("The FMS database failed verification. It is most likely corrupt!"); + } + else if(m_displayhelp) { } else if(m_showoptions) @@ -162,6 +181,15 @@ int FMSApp::main(const std::vector &args) else { logger().information("FMS startup v"FMS_VERSION); + logger().information("Using SQLite "SQLITE_VERSION); + + std::string tempval=""; + Option::Instance()->Get("VacuumOnStartup",tempval); + if(tempval=="true") + { + logger().information("VACUUMing database"); + SQLite3DB::DB::Instance()->Execute("VACUUM;"); + } StartThreads(); @@ -235,6 +263,10 @@ void FMSApp::StartThreads() { logger().trace("FMSApp::StartThreads starting HTTPThread"); m_threads.Start(new HTTPThread()); + if(isInteractive()) + { + std::cout << "Started HTTP Thread" << std::endl; + } } else { @@ -247,6 +279,10 @@ void FMSApp::StartThreads() { logger().trace("FMSApp::StartThreads starting NNTPListener"); m_threads.Start(new NNTPListener()); + if(isInteractive()) + { + std::cout << "Started NNTP Thread" << std::endl; + } } else { @@ -259,6 +295,10 @@ void FMSApp::StartThreads() { logger().trace("FMSApp::StartThreads starting FreenetMasterThread"); m_threads.Start(new FreenetMasterThread()); + if(isInteractive()) + { + std::cout << "Started Freenet FCP Thread" << std::endl; + } } else {