X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain.cpp;h=be5ff2fae56ffead6241d1b873c48e680202413d;hb=HEAD;hp=17d6b6757f2c0721018713f9f69592d4a208dc11;hpb=f60495a029c54358f82956482fe203fe2b7b5b23;p=fms.git diff --git a/src/main.cpp b/src/main.cpp index 17d6b67..be5ff2f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,130 +1,4 @@ -#include "../include/global.h" -#include "../include/commandthread.h" -#include "../include/threadcontroller.h" +#include "../include/fmsapp.h" +#include -#include -#include -#include - -#ifdef _WIN32 - #include "../include/fmsservice.h" -#else - #include "../include/fmsdaemon.h" -#endif - -#ifdef XMEM - #include -#endif - -int main(int argc, char *argv[]) -{ - - #ifdef XMEM - xmem_disable_print(); - #endif - - // check arguments - if(argc>1) - { - #ifndef _WIN32 - if(argv[1] && strncmp(argv[1],"-d",2)==0) - { - Daemonize(); - } - #else - if(argv[1] && strncmp(argv[1],"-i",2)==0) - { - if(ServiceIsInstalled()) - { - std::cout << "FMS Service is already installed" << std::endl; - } - else - { - if(ServiceInstall()) - { - std::cout << "FMS Service Installed" << std::endl; - } - else - { - std::cout << "Error installing FMS Service" << std::endl; - } - } - return 0; - } - else if(argv[1] && strncmp(argv[1],"-u",2)==0) - { - if(ServiceIsInstalled()) - { - if(ServiceUninstall()) - { - std::cout << "FMS Service uninstalled" << std::endl; - } - else - { - std::cout << "There was a problem uninstalling the service" << std::endl; - } - } - else - { - std::cout << "FMS Service is not currently installed" << std::endl; - } - return 0; - } - else if(argv[1] && strncmp(argv[1],"-s",2)==0) - { - if(ServiceStart()) - { - } - else - { - std::cout << "FMS Service could not be started at this time" << std::endl; - } - return 0; - } - #endif - } - - signal(SIGINT,SigHandler); - signal(SIGTERM,SigHandler); - signal(SIGABRT,SigHandler); -#ifdef _WIN32 - signal(SIGBREAK,SigHandler); -#endif - - std::cout << "FMS Running in console mode." << std::endl; - std::cout << "Use the administration pages, or CTRL+C to exit" << std::endl << std::endl; - std::cout << "Available command line arguments:" << std::endl; -#ifdef _WIN32 - std::cout << "-i\tinstall service" << std::endl; - std::cout << "-u\tuninstall service" << std::endl; -#else - std::cout << "-d\trun as daemon" << std::endl; -#endif - - MainFunction(); - - return 0; -} - -void MainFunction() -{ - srand(time(NULL)); - - SetupDB(); - SetupDefaultOptions(); - - SetupLogFile(); - - SetupNetwork(); - - LogFile::Instance()->WriteLog(LogFile::LOGLEVEL_INFO,"FMS startup v"FMS_VERSION); - - ThreadController::Instance()->StartThreads(); - - do - { - PThread::Sleep(1000); - }while(!wantshutdown); - - Shutdown(); -} +POCO_SERVER_MAIN(FMSApp);