void main(int argc, char **argv) 
{

	bool matched  = false;
	if (argv[0]) {
		if (argv[1]) {
			if (!strcmp(argv[1], "install")) {
				removeService();
				installService(argv[2]);
				matched = true;
			}
			if (!strcmp(argv[1], "remove")) {
				removeService();
				matched = true;
			}
		}
	}
	if (matched) {
		return;
	}
	_chdir(argv[1]);

	SERVICE_TABLE_ENTRY ServiceTable[2];
	ServiceTable[0].lpServiceName = "Stream Transcoder V3";
	ServiceTable[0].lpServiceProc = (LPSERVICE_MAIN_FUNCTION)ServiceMain;

	ServiceTable[1].lpServiceName = NULL;
	ServiceTable[1].lpServiceProc = NULL;
	// Start the control dispatcher thread for our service
	StartServiceCtrlDispatcher(ServiceTable);  
}
Example #2
0
bool 
CArchAppUtilWindows::parseArg(const int& argc, const char* const* argv, int& i)
{
	if (app().isArg(i, argc, argv, NULL, "--service")) {

		const char* action = argv[++i];

		if (_stricmp(action, "install") == 0) {
			installService();
		}
		else if (_stricmp(action, "uninstall") == 0) {
			uninstallService();
		}
		else if (_stricmp(action, "start") == 0) {
			startService();
		}
		else if (_stricmp(action, "stop") == 0) {
			stopService();
		}
		else {
			LOG((CLOG_ERR "unknown service action: %s", action));
			app().m_bye(kExitArgs);
		}
		app().m_bye(kExitSuccess);
	}
	else if (app().isArg(i, argc, argv, NULL, "--debug-service-wait")) {

		app().argsBase().m_debugServiceWait = true;
	}
	else if (app().isArg(i, argc, argv, NULL, "--relaunch")) {

		app().argsBase().m_relaunchMode = true;
	}
	else if (app().isArg(i, argc, argv, NULL, "--exit-pause")) {

		app().argsBase().m_pauseOnExit = true;
	}
	else if (app().isArg(i, argc, argv, NULL, "--no-tray")) {

		app().argsBase().m_disableTray = true;
	}
	else {
		// option not supported here
		return false;
	}

	return true;
}
int main (int argc, char *argv[]) 
{
    if (argc < 2)
    {
        printf (PACKAGE_STRING "\n\n"
                "Usage: icecastService [remove] | [install <path>]\n"
                "       icecastService -c icecast.xml\n\n");
        return -1;
    }
    if (!strcmp(argv[1], "install"))
    {
        if (argc > 2)
            installService(argv[2]);
        else
            printf ("install requires a path arg as well\n");
        Sleep (1000);
        return 0;
    }
    if (!strcmp(argv[1], "remove") || !strcmp(argv[1], "uninstall"))
    {
        removeService();
        return 0;
    }

    if (strcmp (argv[1], "-c") == 0)
        return run_server (argc, argv);

    if (_chdir(argv[1]) < 0)
    {
        char buffer [256];
        snprintf (buffer, sizeof(buffer), "Unable to change to directory %s", argv[1]);
        MessageBox (NULL, buffer, NULL, MB_SERVICE_NOTIFICATION);
        return -1;
    }

    SERVICE_TABLE_ENTRY ServiceTable[2];
    ServiceTable[0].lpServiceName = (char*)PACKAGE_STRING;
    ServiceTable[0].lpServiceProc = (LPSERVICE_MAIN_FUNCTION)ServiceMain;

    ServiceTable[1].lpServiceName = NULL;
    ServiceTable[1].lpServiceProc = NULL;
    // Start the control dispatcher thread for our service
    if (StartServiceCtrlDispatcher (ServiceTable) == 0)
        MessageBox (NULL, "StartServiceCtrlDispatcher failed", NULL, MB_SERVICE_NOTIFICATION);
    return 0;
}
Example #4
0
int main(int argc, char* argv[])
{
	SERVICE_TABLE_ENTRY dispatchTable[] = {
        {SERVICENAME, serviceMain },
        {NULL, NULL }
    };
	if(argc > 1) {
		if(_tcsicmp(_T("-run"), argv[1]) == 0) {
			bStandAlone = TRUE;
			fillCP();
			if (argc > 2) {
				if (*(argv[2]+strlen(argv[2])-1) == '\\')
					*(argv[2]+strlen(argv[2])-1) = 0;
				installDir = _strdup(argv[2]);
			} 				

			if (createJVM()) {
				run();
			}
			cleanup();
		} else if(_tcsicmp(_T("-install"), argv[1]) == 0 || _tcsicmp(_T("-installa"), argv[1]) == 0) {
			// TODO use strstr
			// if (strstr(argv[1], _T("-install")) == argv[1])
			if (argc < 3) {
				usage();
				return -1;
			}
			scm = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
			installService(argc<5?SERVICENAME:argv[4], argc<6?SERVICENAME:argv[5],
				argc<7?argv[0]:argv[6], NULL, 0, argv[2], argc<4?NULL:argv[3], argc<8?NULL:argsToLine(argc-7, argv+7),
				_tcsicmp(_T("-installa"), argv[1]) == 0?"rogatkin/app/Main":NULL);
			CloseServiceHandle(scm);
		} else if(_tcsicmp(_T("-uninstall"), argv[1]) == 0) {
			scm = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
			unistallService(argc>2?argv[2]:SERVICENAME);
			CloseServiceHandle(scm);
		} else if(_tcsicmp(_T("-help"), argv[1]) == 0)
			usage();
	} else {
		if (!StartServiceCtrlDispatcher(dispatchTable)) {
			logServiceMessage(_T("StartServiceCtrlDispatcher failed."), EVENTLOG_ERROR_TYPE);
		}
	}

	return 0;
}
Example #5
0
int main(int argc, char **argv) 
{
    if (argc < 2)
    {
        printf ("Usage:\n %s  remove\n %s  install path\n", argv[0], argv[0]);
        return 0;
    }
    if (!strcmp(argv[1], "install"))
    {
        if (argc > 2)
        {
            printf ("Installing service from %s\n", argv[2]);
            installService(argv[2]);
        }
        else
            printf ("install requires a path arg as well\n");
        Sleep (2000);
        return 0;
    }
    if (!strcmp(argv[1], "remove") || !strcmp(argv[1], "uninstall"))
    {
        printf ("removing service\n");
        removeService();
        Sleep (2000);
        return 0;
    }

    if (_chdir(argv[1]) < 0)
    {
        printf ("unable to change to directory %s\n", argv[1]);
        Sleep (2000);
        return 0;
    }

	SERVICE_TABLE_ENTRY ServiceTable[2];
	ServiceTable[0].lpServiceName = PACKAGE_STRING;
	ServiceTable[0].lpServiceProc = (LPSERVICE_MAIN_FUNCTION)ServiceMain;

	ServiceTable[1].lpServiceName = NULL;
	ServiceTable[1].lpServiceProc = NULL;
	// Start the control dispatcher thread for our service
	StartServiceCtrlDispatcher(ServiceTable);  

    return 0;
}
void ServiceInstaller::checkServiceState()
{
	QtServiceController controller(serviceName);
	if(controller.isInstalled()){
		ui.installButton->setText("Uninstall Service");
		ui.messageLabel->setText(QString("\"<b>%1</b>\" is installed.").arg(serviceName));
		ui.serviceStart->hide();
		connect(ui.installButton, SIGNAL(clicked()), this, SLOT(uninstallService()));
	}
	else
	{
		ui.destinationPath->setText(QString("%1\\SigmaRD\\%2").arg(getenv("ProgramFiles(x86)"), serviceName));
		ui.installButton->setText("Install Service");
		ui.messageLabel->setText(QString("Follow instructions to install \"<b>%1</b>\" service.").arg(serviceName));
		ui.serviceStart->show();
		connect(ui.installButton, SIGNAL(clicked()), this, SLOT(installService()));
	}
}
Example #7
0
int main(int argc, char **argv)
{
  AString strCommand(argv[1]);
  try
  {
    if (strCommand.equalsNoCase("install"))
    {
      if (installService())
        std::cout << "Service installed." << std::endl;
      else
        std::cout << "Service install failed." << std::endl;
    }
    else if (strCommand.equalsNoCase("remove"))
    {
      if (removeService())
        std::cout << "Service removed." << std::endl;
      else
        std::cout << "Service remove failed." << std::endl;
    }
    else
    {
      // When service dispatch action is requested this main() is called with no parameters
      // This connects the handler with service
      connectToServiceDispatch();
    }
  }
  catch(AException& ex)
  {
    AFILE_TRACER_DEBUG_MESSAGE((AString("main: ")+ex.what()).c_str(), NULL);
    std::cerr << ex.what() << std::endl;
  }
  catch(std::exception& ex)
  {
    AFILE_TRACER_DEBUG_MESSAGE((AString("main: ")+ex.what()).c_str(), NULL);
    std::cerr << ex.what() << std::endl;
  }
  catch(...)
  {
    AFILE_TRACER_DEBUG_MESSAGE("main: Unknown exception", NULL);
    std::cerr << "Unknown exception" << std::endl;
  }

  return 1;
}
/*
 * Execute the 'install service' command
 */
int InstallCommand::execute()
{

	int commandStatus = COMMAND_FAILURE;
	bool lookupError = true;

	if (!parametersValid)
	{
		cerr << "JavaService install command parameters not valid, or incomplete";
	}
	else if (isServiceInstalled(lookupError) && !lookupError)
	{
		cerr << "The " << getServiceName() << " service is already installed";
	}
	else if (lookupError)
	{
		cerr << "Error while checking to see if " << getServiceName() << " service is installed" << endl;
		printLastError();
	}
	else
	{
		bool installed = installService();

		if (installed)
		{
			commandStatus = COMMAND_SUCCESS; // success, even if saving config fails

			if (!saveServiceConfig())
			{
				cerr << "Error saving " << getServiceName() << "  service configuration (service installed)" << endl;
				printLastError();
			}
		}
		else
		{
			cerr << "Error attempting to install " << getServiceName() << "  service" << endl;
			printLastError();
		}
	}

	return commandStatus;
}
Example #9
0
static bool process(cchar *operation)
{
    bool    rc;

    rc = 1;

    if (smatch(operation, "install")) {
        rc = installService(app->serviceArgs);

    } else if (smatch(operation, "uninstall")) {
        rc = removeService(1);

    } else if (smatch(operation, "enable")) {
        rc = enableService(1);

    } else if (smatch(operation, "disable")) {
        rc = enableService(0);

    } else if (smatch(operation, "start")) {
        rc = startService();

    } else if (smatch(operation, "stop")) {
        rc = removeService(0);

    } else if (smatch(operation, "reload")) {
        rc = process("restart");

    } else if (smatch(operation, "restart")) {
        process("stop");
        return process("start");

    } else if (smatch(operation, "run")) {
        /*
            This thread will block if being started by SCM. While blocked, the serviceMain 
            will be called which becomes the effective main program. 
         */
        startDispatcher(serviceMain);
    }
    return rc;
}
void ServiceInstaller::installService()
{
	QString servicePath = serviceExecutable;
	
	// Service Registration Phase
	if (QtServiceController::install(servicePath, QString(), QString()))
	{
		disconnect(ui.installButton, SIGNAL(clicked()), this, SLOT(installService()));
		if (ui.serviceStart->isChecked())
		{
			QtServiceController controller(serviceName);
			controller.start();
		}
		QMessageBox::information(this, "Service Installed", QString("\"%1\" succesfully installed.").arg(serviceName));
		checkServiceState();
	}
	else
	{
		QMessageBox::critical(this, "Install Failed", QString("An error occured while installing \"%1\".").arg(serviceName));
		qApp->exit();
	}
}
int main(int argc, char* argv[])
{
	char *arg;

    if (!initService())
	{
		logMessage("ERROR: Failed to initialise service.\n");
		return 1;
	}

	if (argc == 1)
	{
		/* Service table entry to start service. */
		SERVICE_TABLE_ENTRY lpServiceTable[] = 
		{
			{SERVICE_NAME, (LPSERVICE_MAIN_FUNCTION)ServiceMain},
			{0, 0}
		};

		/* Start the service. */
		if (!StartServiceCtrlDispatcher(lpServiceTable))
		{
			DWORD err = GetLastError();
			if (err == ERROR_FAILED_SERVICE_CONTROLLER_CONNECT)
			{
				logMessage("ERROR: Can't run service as a command line program, it must be installed as a service and the '%s' service started.\n", SERVICE_NAME);
				printf("Can't run service as a command line program, it must be installed as a service and the '%s' service started.\n\n", SERVICE_NAME);
			}
			else if (err == ERROR_INVALID_DATA)
			{
				logMessage("BUG: Invalid service dispatch table information.\n");
			}
			else if (err == ERROR_SERVICE_ALREADY_RUNNING)
			{
				logMessage("ERROR: Failed to start service %s because it is already running.\n", SERVICE_NAME);
			}
			else
			{
				logMessage("ERROR: Failed to start service %s because it is already running.\n", SERVICE_NAME);
			}
		}
	}
	else
	{
		arg = argv[1];
		while (*arg != '\0' && *arg == '-') arg++;
		if (_stricmp("install", arg) == 0)
		{
			/* Install the service. */
			return installService();
		}
		else if (_stricmp("uninstall", arg)  == 0)
		{
			/* Remove the service. */
			return uninstallService();
		}
		else if (_stricmp("help", arg) == 0 || *arg == 'h')
		{		
			/* Print help. */
			printf("Usage: %s [install]|[uninstall]\n\n", argv[0]);
			printf("\t- install   - Installs the %s service. For installation to\n", SERVICE_NAME);
			printf("\t              succeed the service must not be currently install.\n");
			printf("\t- uninstall - Removes the service %s.\n\n", SERVICE_NAME);
			printf("Once the service is installed the following Windows commands allow\n");
			printf("the %s service to started and stopped\n\n", SERVICE_NAME);
			printf("\t- Start %s: net start \"%s\"\n", SERVICE_NAME, SERVICE_NAME);
			printf("\t- Stop %s:  net stop \"%s\"\n\n", SERVICE_NAME, SERVICE_NAME);
			printf("Alternatively, the %s service may be started or stopped using the\n", SERVICE_NAME);
			printf("Windows Services Administrative Tool, located in:\n\n");
			printf("\tControl Panel -> Administrative Tools -> Services\n\n");
		}
	}

	return 0;
}
Example #12
0
int main(int argc,char **argv) 
{
    InitModuleObjects();
    EnableSEHtoExceptionMapping();
#ifndef __64BIT__
    // Restrict stack sizes on 32-bit systems
    Thread::setDefaultStackSize(0x10000);   // 64K stack (also set in windows DSP)
#endif
    Owned<IFile> sentinelFile = createSentinelTarget();
    removeSentinelFile(sentinelFile);

    SocketEndpoint listenep;
    unsigned sendbufsize = 0;
    unsigned recvbufsize = 0;
    int i = 1;
    bool isdaemon = (memicmp(argv[0]+strlen(argv[0])-4,".exe",4)==0);
    // bit of a kludge for windows - if .exe not specified then not daemon
    bool locallisten = false;
    const char *logdir=NULL;
    bool requireauthenticate = false;
    StringBuffer logDir;
    StringBuffer instanceName;

   //Get SSL Settings
    const char *    sslCertFile;
    bool            useSSL;
    unsigned short  dafsPort;//DAFILESRV_PORT or SECURE_DAFILESRV_PORT
    querySecuritySettings(&useSSL, &dafsPort, &sslCertFile, NULL);

    unsigned parallelRequestLimit = DEFAULT_PARALLELREQUESTLIMIT;
    unsigned throttleDelayMs = DEFAULT_THROTTLEDELAYMS;
    unsigned throttleCPULimit = DEFAULT_THROTTLECPULIMIT;

    Owned<IPropertyTree> env = getHPCCEnvironment();
    if (env)
    {
        StringBuffer dafilesrvPath("Software/DafilesrvProcess");
        if (instanceName.length())
            dafilesrvPath.appendf("[@name=\"%s\"]", instanceName.str());
        IPropertyTree *daFileSrv = env->queryPropTree(dafilesrvPath);
        if (daFileSrv)
        {
            // global DaFileSrv settings:
            parallelRequestLimit = daFileSrv->getPropInt("@parallelRequestLimit", DEFAULT_PARALLELREQUESTLIMIT);
            throttleDelayMs = daFileSrv->getPropInt("@throttleDelayMs", DEFAULT_THROTTLEDELAYMS);
            throttleCPULimit = daFileSrv->getPropInt("@throttleCPULimit", DEFAULT_THROTTLECPULIMIT);

            // any overrides by Instance definitions?
            // NB: This won't work if netAddress is "." or if we start supporting hostnames there
            StringBuffer ipStr;
            queryHostIP().getIpText(ipStr);
            VStringBuffer daFileSrvPath("Instance[@netAddress=\"%s\"]", ipStr.str());
            IPropertyTree *dafileSrvInstance = daFileSrv->queryPropTree(daFileSrvPath);
            if (dafileSrvInstance)
            {
                parallelRequestLimit = dafileSrvInstance->getPropInt("@parallelRequestLimit", parallelRequestLimit);
                throttleDelayMs = dafileSrvInstance->getPropInt("@throttleDelayMs", throttleDelayMs);
                throttleCPULimit = dafileSrvInstance->getPropInt("@throttleCPULimit", throttleCPULimit);
            }
        }
    }

    while (argc>i) {
        if (stricmp(argv[i],"-D")==0) {
            i++;
            isdaemon = true;
        }
        else if (stricmp(argv[i],"-R")==0) { // for remote run
            i++;
#ifdef _WIN32
            isdaemon = false;
#else
            isdaemon = true;
#endif
        }
        else if (stricmp(argv[i],"-A")==0) { 
            i++;
            requireauthenticate = true;
        }
        else if ((argv[i][0]=='-')&&(toupper(argv[i][1])=='T')&&(!argv[i][2]||isdigit(argv[i][2]))) {
            if (argv[i][2])
                setDafsTrace(NULL,(byte)atoi(argv[i]+2));
            i++;
            isdaemon = false;
        }
        else if ((argc>i+1)&&(stricmp(argv[i],"-L")==0)) { 
            i++;
            logDir.clear().append(argv[i++]);
        }
        else if ((argc>i+1)&&(stricmp(argv[i],"-I")==0)) {
            i++;
            instanceName.clear().append(argv[i++]);
        }
        else if (stricmp(argv[i],"-LOCAL")==0) { 
            i++;
            locallisten = true;
        }
        else if (stricmp(argv[i],"-NOSSL")==0) {//overrides config setting
            i++;
            if (useSSL)
            {
                PROGLOG("DaFileSrv SSL specified in config but overridden by -NOSSL in command line");
                useSSL = false;
                dafsPort = DAFILESRV_PORT;
            }
        }
        else
            break;
    }

    if (useSSL && !sslCertFile)
    {
        ERRLOG("DaFileSrv SSL specified but certificate file information missing from environment.conf");
        exit(-1);
    }

    if (0 == logDir.length())
    {
        getConfigurationDirectory(NULL,"log","dafilesrv",instanceName.str(),logDir);
        if (0 == logDir.length())
            logDir.append(".");
    }
    if (instanceName.length())
    {
        addPathSepChar(logDir);
        logDir.append(instanceName.str());
    }

#ifdef _WIN32
    if ((argc>i)&&(stricmp(argv[i],"-install")==0)) {
        if (installService(DAFS_SERVICE_NAME,DAFS_SERVICE_DISPLAY_NAME,NULL)) {
            PROGLOG(DAFS_SERVICE_DISPLAY_NAME " Installed");
            return 0;
        }
        return 1;
    }
    if ((argc>i)&&(stricmp(argv[i],"-remove")==0)) {
        if (uninstallService(DAFS_SERVICE_NAME,DAFS_SERVICE_DISPLAY_NAME)) {
            PROGLOG(DAFS_SERVICE_DISPLAY_NAME " Uninstalled");
            return 0;
        }
        return 1;
    }
#endif
    if (argc == i)
        listenep.port = dafsPort;
    else {
        if (strchr(argv[i],'.')||!isdigit(argv[i][0]))
            listenep.set(argv[i], dafsPort);
        else
            listenep.port = atoi(argv[i]);
        if (listenep.port==0) {
            usage();
            exit(-1);
        }
        sendbufsize = (argc>i+1)?(atoi(argv[i+1])*1024):0;
        recvbufsize = (argc>i+2)?(atoi(argv[i+2])*1024):0;
    }
    if (isdaemon) {
#ifdef _WIN32
        class cserv: public CService
        {
            bool stopped;
            bool started;
            SocketEndpoint listenep;
            bool useSSL;
            bool requireauthenticate;

            
            class cpollthread: public Thread
                
            {
                cserv *parent;
            public:
                cpollthread( cserv *_parent ) 
                : Thread("CService::cpollthread"), parent(_parent) 
                {
                }
                int run() 
                { 
                    while (parent->poll())
                        Sleep(1000);
                    return 1;
                }
            } pollthread;
            Owned<IRemoteFileServer> server;

        public:

            cserv(SocketEndpoint _listenep, bool _useSSL)
                : listenep(_listenep),useSSL(_useSSL),pollthread(this)
            {
                stopped = false;
                started = false;
            }

            virtual ~cserv()
            {
                stopped = true;
                if (started)
                    pollthread.join();
            }

            bool init()
            {
                PROGLOG(DAFS_SERVICE_DISPLAY_NAME " Initialized");
                started = true;
                pollthread.start();
                return true;
            }

            bool poll()
            {
                if (stopped||!running()) {
                    PROGLOG(DAFS_SERVICE_DISPLAY_NAME " Stopping");
                    if (server) {
                        server->stop();
                        server.clear();
                    }
                    return false;
                }
                return true;
            }

            void run()
            {
                // Get params from HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\DaFileSrv\Parameters
                
                int requireauthenticate=0;
                HKEY hkey;
                if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,
                                 "SYSTEM\\CurrentControlSet\\Services\\DaFileSrv\\Parameters",
                                 0,
                                 KEY_QUERY_VALUE,
                                 &hkey) == ERROR_SUCCESS) {
                    DWORD dwType = 0;
                    DWORD dwSize = sizeof(requireauthenticate);
                    RegQueryValueEx(hkey,
                                    "RequireAuthentication",
                                    NULL,
                                    &dwType,
                                    (BYTE*)&requireauthenticate,
                                    &dwSize);
                    RegCloseKey(hkey);
                }
                StringBuffer eps;
                if (listenep.isNull())
                    eps.append(listenep.port);
                else
                    listenep.getUrlStr(eps);
                enableDafsAuthentication(requireauthenticate!=0);
                PROGLOG("Opening " DAFS_SERVICE_DISPLAY_NAME " on %s%s", useSSL?"SECURE ":"",eps.str());
                const char * verstring = remoteServerVersionString();
                PROGLOG("Version: %s", verstring);
                PROGLOG("Authentication:%s required",requireauthenticate?"":" not");
                PROGLOG(DAFS_SERVICE_DISPLAY_NAME " Running");
                server.setown(createRemoteFileServer(parallelRequestLimit, throttleDelayMs, throttleCPULimit));
                try {
                    server->run(listenep, useSSL);
                }
                catch (IException *e) {
                    EXCLOG(e,DAFS_SERVICE_NAME);
                    e->Release();
                }
                PROGLOG(DAFS_SERVICE_DISPLAY_NAME " Stopped");
                stopped = true;
            }
        } service(listenep, useSSL);
        service.start();
        return 0;
#else
        int ret = initDaemon();
        if (ret)
            return ret;
#endif
    }
    {
        Owned<IComponentLogFileCreator> lf = createComponentLogFileCreator(logDir.str(), "DAFILESRV");
        lf->setCreateAliasFile(false);
        lf->setMaxDetail(TopDetail);
        lf->beginLogging();
    }

    PROGLOG("Parallel request limit = %d, throttleDelayMs = %d, throttleCPULimit = %d", parallelRequestLimit, throttleDelayMs, throttleCPULimit);

    const char * verstring = remoteServerVersionString();
    StringBuffer eps;
    if (listenep.isNull())
        eps.append(listenep.port);
    else
        listenep.getUrlStr(eps);
    enableDafsAuthentication(requireauthenticate);
    PROGLOG("Opening Dali File Server on %s%s", useSSL?"SECURE ":"",eps.str());
    PROGLOG("Version: %s", verstring);
    PROGLOG("Authentication:%s required",requireauthenticate?"":" not");
    startPerformanceMonitor(10*60*1000, PerfMonStandard);
    server.setown(createRemoteFileServer(parallelRequestLimit, throttleDelayMs, throttleCPULimit));
    writeSentinelFile(sentinelFile);
    try {
        server->run(listenep, useSSL);
    }
    catch (IException *e) {
        EXCLOG(e,"DAFILESRV");
        e->Release();
    }
    if (server)
        server->stop();
    server.clear();
    PROGLOG("Stopped Dali File Server");

    return 0;
}
Example #13
0
void main(int argc, char **argv)
{
	// Statup wx
	wxInitialize();

	wxFileName file = wxString::FromAscii(*argv++);
	file.MakeAbsolute();
	wxString executable = file.GetFullPath();

	if (argc < 3)
	{
		usage(executable);
		return;
	}

	wxString command;
	command = wxString::FromAscii(*argv++);

	if (command != wxT("DEBUG"))
	{
		serviceName = wxString::FromAscii(*argv++);
		argc -= 3;
	}
	else
		argc -= 2;

	if (command == wxT("INSTALL"))
	{
		wxString displayname = _("PostgreSQL Scheduling Agent - ") + serviceName;
		wxString args = wxT("RUN ") + serviceName;

		while (argc-- > 0)
		{
			if (argv[0][0] == '-')
			{
				switch (argv[0][1])
				{
					case 'u':
					{
						user = getArg(argc, argv);
						break;
					}
					case 'p':
					{
						password = getArg(argc, argv);
						break;
					}
					case 'd':
					{
						displayname = getArg(argc, argv);
						break;
					}
					default:
					{
						args += wxT(" ") + wxString::FromAscii(*argv);
						break;
					}
				}
			}
			else
			{
				args += wxT(" ") + wxString::FromAscii(*argv);
			}

			argv++;
		}

		bool rc = installService(serviceName, executable, args, displayname, user, password);
	}
	else if (command == wxT("REMOVE"))
	{
		bool rc = removeService(serviceName);
	}
	else if (command == wxT("DEBUG"))
	{
		setupForRun(argc, argv, true, executable);

		initService();
#if START_SUSPENDED
		continueService();
#endif

		WaitForSingleObject(threadHandle, INFINITE);
	}
	else if (command == wxT("RUN"))
	{
		wxString app = _("pgAgent Service");

		SERVICE_TABLE_ENTRY serviceTable[] =
		{ (LPWSTR)app.wc_str(), serviceMain, 0, 0};

		setupForRun(argc, argv, false, executable);

		if (!StartServiceCtrlDispatcher(serviceTable))
		{
			DWORD rc = GetLastError();
			if (rc)
			{
			}
		}
	}
	else
	{
		usage(executable);
	}

	return;
}
Example #14
0
/*
 *
 * Main Windows entry point.
 *
 * We parse the command line and either calls the main App
 *   or starts up the service.
 */
int WINAPI WinMain(HINSTANCE Instance, HINSTANCE /*PrevInstance*/, PSTR CmdLine, 
                   int /*show*/)
{
   char *cmdLine = CmdLine;
   char *wordPtr, *tempPtr;
   int i, quote;
   OSVERSIONINFO osversioninfo;
   osversioninfo.dwOSVersionInfoSize = sizeof(osversioninfo);


   /* Save the application instance and main thread id */
   appInstance = Instance;
   mainthreadId = GetCurrentThreadId();

   if (GetVersionEx(&osversioninfo) && 
       osversioninfo.dwPlatformId == VER_PLATFORM_WIN32_NT) {
      have_service_api = true;
   }

   main_pid = getpid();
   main_tid = pthread_self();

   INITCOMMONCONTROLSEX initCC = {
      sizeof(INITCOMMONCONTROLSEX), 
      ICC_STANDARD_CLASSES
   };

   InitCommonControlsEx(&initCC);

   /*
    * Funny things happen with the command line if the
    * execution comes from c:/Program Files/bacula/bacula.exe
    * We get a command line like: Files/bacula/bacula.exe" options
    * I.e. someone stops scanning command line on a space, not
    * realizing that the filename is quoted!!!!!!!!!!
    * So if first character is not a double quote and
    * the last character before first space is a double
    * quote, we throw away the junk.
    */

   wordPtr = cmdLine;
   while (*wordPtr && *wordPtr != ' ')
      wordPtr++;
   if (wordPtr > cmdLine)      /* backup to char before space */
      wordPtr--;
   /* if first character is not a quote and last is, junk it */
   if (*cmdLine != '"' && *wordPtr == '"') {
      cmdLine = wordPtr + 1;
   }

   /*
    * Build Unix style argc *argv[] for the main "Unix" code
    *  stripping out any Windows options 
    */

   /* Don't NULL command_args[0] !!! */
   for (i=1;i<MAX_COMMAND_ARGS;i++) {
      command_args[i] = NULL;
   }

   char *pszArgs = bstrdup(cmdLine);
   wordPtr = pszArgs;
   quote = 0;
   while  (*wordPtr && (*wordPtr == ' ' || *wordPtr == '\t'))
      wordPtr++;
   if (*wordPtr == '\"') {
      quote = 1;
      wordPtr++;
   } else if (*wordPtr == '/') {
      /* Skip Windows options */
      while (*wordPtr && (*wordPtr != ' ' && *wordPtr != '\t'))
         wordPtr++;
      while  (*wordPtr && (*wordPtr == ' ' || *wordPtr == '\t'))
         wordPtr++;
   }
   if (*wordPtr) {
      while (*wordPtr && num_command_args < MAX_COMMAND_ARGS) {
         tempPtr = wordPtr;
         if (quote) {
            while (*tempPtr && *tempPtr != '\"')
               tempPtr++;
            quote = 0;
         } else {
            while (*tempPtr && *tempPtr != ' ')
            tempPtr++;
         }
         if (*tempPtr)
            *(tempPtr++) = '\0';
         command_args[num_command_args++] = wordPtr;
         wordPtr = tempPtr;
         while (*wordPtr && (*wordPtr == ' ' || *wordPtr == '\t'))
            wordPtr++;
         if (*wordPtr == '\"') {
            quote = 1;
            wordPtr++;
         }
      }
   }

   /*
    * Now process Windows command line options. Most of these options
    *  are single shot -- i.e. we accept one option, do something and
    *  terminate.
    */
   for (i = 0; i < (int)strlen(cmdLine); i++) {
      char *p = &cmdLine[i];

      if (*p <= ' ') {
         continue;                    /* toss junk */
      }

      if (*p != '/') {
         break;                       /* syntax error */
      }

      /* Start as a service? */
      if (strncasecmp(p, "/service", 8) == 0) {
         return baculaServiceMain();      /* yes, run as a service */
      }

      /* Stop any running copy? */
      if (strncasecmp(p, "/kill", 5) == 0) {
         return stopRunningBacula();
      }

      /* Run app as user program? */
      if (strncasecmp(p, "/run", 4) == 0) {
         return BaculaAppMain();         /* yes, run as a user program */
      }

      /* Install Bacula in registry? */
      if (strncasecmp(p, "/install", 8) == 0) {
         return installService(p+8);    /* Pass command options */
      }

      /* Remove Bacula registry entry? */
      if (strncasecmp(p, "/remove", 7) == 0) {
         return removeService();
      }

      /* Set debug mode? -- causes more dialogs to be displayed */
      if (strncasecmp(p, "/debug", 6) == 0) {
         opt_debug = true;
         i += 6;                /* skip /debug */
         continue;
      }

      /* Display help? -- displays usage */
      if (strncasecmp(p, "/help", 5) == 0) {
         MessageBox(NULL, usage, APP_DESC, MB_OK|MB_ICONINFORMATION);
         return 0;
      }
      
      MessageBox(NULL, cmdLine, _("Bad Command Line Option"), MB_OK);

      /* Show the usage dialog */
      MessageBox(NULL, usage, APP_DESC, MB_OK | MB_ICONINFORMATION);

      return 1;
   }
   return BaculaAppMain();
}
Example #15
0
void main(int argc, char **argv)
{
  // The StartServiceCtrlDispatcher requires this table to specify
  // the ServiceMain function to run in the calling process. The first
  // member in this example is actually ignored, since we will install
  // our service as a SERVICE_WIN32_OWN_PROCESS service type. The NULL
  // members of the last entry are necessary to indicate the end of
  // the table;
  SERVICE_TABLE_ENTRY serviceTable[] =
    {
      { TEXT(SZSERVICENAME), (LPSERVICE_MAIN_FUNCTION)serviceMain },
      { NULL, NULL }
    };

  TCHAR szAppParameters[8192];

  if(!isWinNT()) {
    convertArgListToArgString((LPTSTR) szAppParameters,0, argc, argv);
    if(NULL == szAppParameters){
      _tprintf(TEXT("Could not create AppParameters string.\n"));
    }
    invokeNtop(szAppParameters);
    return;
  }

  isNtopAservice = 0;

  // This app may be started with one of three arguments, /i, /r, and
  // /c, or /?, followed by actual program arguments. These arguments
  // indicate if the program is to be installed, removed, run as a
  // console application, or to display a usage message.
  if(argc > 1){
    if(!stricmp(argv[1],"/i")){
      installService(argc,argv);
      printf("NOTE: the default password for the 'admin' user has been set to 'admin'.");
    }
    else if(!stricmp(argv[1],"/r")){
      removeService();
    }
    else if(!stricmp(argv[1],"/c")){
      bConsole = TRUE;
      runService(argc, argv);
    }
    else {
      printf("\nUnrecognized option: %s\n", argv[1]);
      printf("Available options:\n");
      printf("/i [ntopng options] - Install ntopng as service\n");
      printf("/c                  - Run ntopng on a console\n");
      printf("/r                  - Deinstall the service\n");
      printf("/h                  - Prints this help\n\n");

      usage();
    }

    exit(0);
  }

  // If main is called without any arguments, it will probably be by the
  // service control manager, in which case StartServiceCtrlDispatcher
  // must be called here. A message will be printed just in case this
  // happens from the console.
  printf("\nNOTE:\nUnder your version of Windows, ntopng is started as a service.\n");
  printf("Please open the services control panel to start/stop ntop,\n");
  printf("or type ntop /h to see all the available options.\n");

  isNtopAservice = 1;
  if(!StartServiceCtrlDispatcher(serviceTable)) {
    printf("\n%s\n", SZFAILURE);
    AddToMessageLog(TEXT(SZFAILURE));
  }
}
Example #16
0
void main(int argc, char **argv)
{
  // The StartServiceCtrlDispatcher requires this table to specify
  // the ServiceMain function to run in the calling process. The first
  // member in this example is actually ignored, since we will install
  // our service as a SERVICE_WIN32_OWN_PROCESS service type. The NULL
  // members of the last entry are necessary to indicate the end of
  // the table;
  SERVICE_TABLE_ENTRY serviceTable[] =
    {
      { TEXT(SZSERVICENAME), (LPSERVICE_MAIN_FUNCTION)serviceMain },
      { NULL, NULL }
    };

  TCHAR szAppParameters[8192];

 // pthread_win32_process_attach_np();

  if(!isWinNT()) {
    convertArgListToArgString((LPTSTR) szAppParameters,0, argc, argv);
    if(NULL == szAppParameters){
      _tprintf(TEXT("Could not create AppParameters string.\n"));
    }
    invokelprobe(szAppParameters);
    return;
  }
  thisIsAservice = 0;

  // This app may be started with one of three arguments, /i, /r, and
  // /c, or /?, followed by actual program arguments. These arguments
  // indicate if the program is to be installed, removed, run as a
  // console application, or to display a usage message.
  if(argc > 1){
    char *service_name = "lprobe for Win32";

    if(!stricmp(argv[1],"/i")){
      if(argc >2)
	installService(argv[2], argc, argv);
      else
	_tprintf(TEXT("/i requires the service name as parameter\n"));
    }
    else if(!stricmp(argv[1],"/r")){
      if(argc >1)
	removeService(argv[2]);
      else
	_tprintf(TEXT("/r requires the service name as parameter\n"));
    }
    else if(!stricmp(argv[1],"/c")){
      bConsole = TRUE;
      runService(argc,argv);
    }
    else{
      if(stricmp(argv[1],"/h")) printf("\nUnrecognized option: %s\n", argv[1]);
      printf("Available options:\n");
      printf("/i <service name> [lprobe options] - Install lprobe as service\n");
      printf("/c [lprobe options]                - Run lprobe on a console\n");
      printf("/r <service name>                  - Deinstall the service\n\n");
      printf("Example:\n"
	     "Install lprobe as a service: 'lprobe /i my_lprobe -i 0 -n 192.168.0.1:2055'\n"
	     "Remove the lprobe service:   'lprobe /r my_lprobe'\n\n");
      printf("Notes:\n"
	     "1. Type 'lprobe /c -h' to see all options\n"
	     "1. In order to reinstall a service with new options\n"
	     "   it is necessary to first remove the service, then add it\n"
	     "   again with the new options.\n"
	     "2. Services are started/stopped using the Services\n"
	     "   control panel item.\n"
	     "3. You can install the lprobe service multiple times\n"
	     "   as long as you use different service names.\n\n");
    }
    exit(0);
  }
  thisIsAservice = 1;

  // If main is called without any arguments, it will probably be by the
  // service control manager, in which case StartServiceCtrlDispatcher
  // must be called here. A message will be printed just in case this
  // happens from the console.
  printf("\nNOTE:\nUnder your version of Windows, lprobe is started as a service.\n");
  printf("Please open the services control panel to start/stop lprobe,\n");
  printf("or type lprobe /h to see all the available options.\n");

  if(!StartServiceCtrlDispatcher(serviceTable)) {
    printf("\n%s\n", SZFAILURE);
    AddToMessageLog(TEXT(SZFAILURE));
  }
}
Example #17
0
int APIENTRY WinMain(HINSTANCE inst, HINSTANCE junk, char *args, int junk2)
{
    char    **argv, *argp, *serviceArgs, *homeDir;
    int     argc, err, nextArg, installFlag;

    mpr = mprCreate(0, NULL, NULL);

    appInst = inst;
    serviceArgs = 0;
    err = 0;
    exiting = 0;
    installFlag = 0;
    homeDir = 0;
    heartBeatPeriod = HEART_BEAT_PERIOD;

    initService();

    mprSetAppName(mpr, BLD_PRODUCT "Angel", BLD_NAME "Angel", BLD_VERSION);
    appName = mprGetAppName(mpr);
    appTitle = mprGetAppTitle(mpr);

    mprSetLogHandler(mpr, logHandler, NULL);

    /*
     *  Create the window 
     */
    if (initWindow() < 0) {
        mprError(mpr, "Can't initialize application Window");
        return FALSE;
    }

    /*
     *  Parse command line arguments
     */
    if (mprMakeArgv(mpr, "", args, &argc, &argv) < 0) {
        return FALSE;
    }
    for (nextArg = 1; nextArg < argc; nextArg++) {
        argp = argv[nextArg];
        if (*argp != '-' || strcmp(argp, "--") == 0) {
            break;
        }

        if (strcmp(argp, "--args") == 0) {
            /*
             *  Args to pass to service when it starts
             */
            if (nextArg >= argc) {
                err++;
            } else {
                serviceArgs = argv[++nextArg];
            }

        } else if (strcmp(argp, "--console") == 0) {
            /*
             *  Allow the service to interact with the console
             */
            createConsole++;

        } else if (strcmp(argp, "--daemon") == 0) {
            /* Ignored on windows */

        } else if (strcmp(argp, "--heartBeat") == 0) {
            /*
             *  Set the heart beat period
             */
            if (nextArg >= argc) {
                err++;
            } else {
                heartBeatPeriod = atoi(argv[++nextArg]) * 1000;
            }

        } else if (strcmp(argp, "--home") == 0) {
            /*
             *  Change to this directory before starting the service
             */
            if (nextArg >= argc) {
                err++;
            } else {
                homeDir = argv[++nextArg];
            }

        } else if (strcmp(argp, "--program") == 0) {
            if (nextArg >= argc) {
                err++;
            } else {
                serviceProgram = argv[++nextArg];
            }

        } else if (strcmp(argp, "--install") == 0) {
            installFlag++;

        } else if (strcmp(argp, "--start") == 0) {
            /*
             *  Start the angel
             */
            if (startService() < 0) {
                return FALSE;
            }
            mprSleep(mpr, 2000);    /* Time for service to really start */

        } else if (strcmp(argp, "--stop") == 0) {
            /*
             *  Stop the  angel
             */
            if (removeService(0) < 0) {
                return FALSE;
            }

        } else if (strcmp(argp, "--uninstall") == 0) {
            /*
             *  Remove the  angel
             */
            if (removeService(1) < 0) {
                return FALSE;
            }

        } else if (strcmp(argp, "--verbose") == 0 || strcmp(argp, "-v") == 0) {
            verbose++;

        } else {
            err++;
        }

        if (err) {
            mprUserError(mpr, 
                "Bad command line: %s\n"
                "  Usage: %s [options] [program args]\n"
                "  Switches:\n"
                "    --args               # Args to pass to service\n"
                "    --console            # Display the service console\n"
                "    --heartBeat interval # Heart beat interval period (secs)\n"
                "    --home path          # Home directory for service\n"
                "    --install            # Install the service\n"
                "    --program            # Service program to start\n"
                "    --start              # Start the service\n"
                "    --stop               # Stop the service\n"
                "    --uninstall          # Uninstall the service",
                args, appName);
            return -1;
        }
    }

    if (installFlag) {
        /*
         *  Install the angel
         */
        if (installService(homeDir, serviceArgs) < 0) {
            return FALSE;
        }
    }

    if (argc <= 1) {
        /*
         *  This will block if we are a service and are being started by the
         *  service control manager. While blocked, the svcMain will be called
         *  which becomes the effective main program. 
         */
        startDispatcher(serviceMain);
    }
    return 0;
}
Example #18
0
int main(int argc,char **argv) 
{
    InitModuleObjects();
    EnableSEHtoExceptionMapping();
#ifndef __64BIT__
    Thread::setDefaultStackSize(0x10000);   // 64K stack (also set in windows DSP)
#endif

    StringBuffer logDir;
#ifdef _WIN32
    logDir.append("c:\\");
#else
    if (checkDirExists("/c$"))
        logDir.append("/c$/");
#endif

    Owned<IFile> sentinelFile = createSentinelTarget();
    removeSentinelFile(sentinelFile);

    SocketEndpoint listenep;
    unsigned sendbufsize = 0;
    unsigned recvbufsize = 0;
    int i = 1;
    bool isdaemon = (memicmp(argv[0]+strlen(argv[0])-4,".exe",4)==0);
    // bit of a kludge for windows - if .exe not specified then not daemon
    bool locallisten = false;
    const char *logdir=NULL;
    bool requireauthenticate = false;
    while (argc>i) {
        if (stricmp(argv[i],"-D")==0) {
            i++;
            isdaemon = true;
        }
        else if (stricmp(argv[i],"-R")==0) { // for remote run
            i++;
#ifdef _WIN32
            isdaemon = false;
#else
            isdaemon = true;
#endif
        }
        else if (stricmp(argv[i],"-A")==0) { 
            i++;
            requireauthenticate = true;
        }
        else if ((argv[i][0]=='-')&&(toupper(argv[i][1])=='T')&&(!argv[i][2]||isdigit(argv[i][2]))) {
            if (argv[i][2])
                setDafsTrace(NULL,(byte)atoi(argv[i]+2));
            i++;
            isdaemon = false;
        }
        else if ((argc>i+1)&&(stricmp(argv[i],"-L")==0)) { 
            i++;
            logDir.clear().append(argv[i++]);
            addPathSepChar(logDir);
        }
        else if (stricmp(argv[i],"-LOCAL")==0) { 
            i++;
            locallisten = true;
        }
        else
            break;
    }

#ifdef _WIN32
    if ((argc>i)&&(stricmp(argv[i],"-install")==0)) {
        if (installService(DAFS_SERVICE_NAME,DAFS_SERVICE_DISPLAY_NAME,NULL)) {
            PROGLOG(DAFS_SERVICE_DISPLAY_NAME " Installed");
            return 0;
        }
        return 1;
    }
    if ((argc>i)&&(stricmp(argv[i],"-remove")==0)) {
        if (uninstallService(DAFS_SERVICE_NAME,DAFS_SERVICE_DISPLAY_NAME)) {
            PROGLOG(DAFS_SERVICE_DISPLAY_NAME " Uninstalled");
            return 0;
        }
        return 1;
    }
#endif
    if (argc == i)
      listenep.port = DAFILESRV_PORT;
    else {
        if (strchr(argv[i],'.')||!isdigit(argv[i][0]))
            listenep.set(argv[i],DAFILESRV_PORT);
        else
            listenep.port = atoi(argv[i]);
        if (listenep.port==0) {
            usage();
            exit(-1);
        }
        sendbufsize = (argc>i+1)?(atoi(argv[i+1])*1024):0;
        recvbufsize = (argc>i+2)?(atoi(argv[i+2])*1024):0;
    }
    if (isdaemon) {
#ifdef _WIN32
        class cserv: public CService
        {
            bool stopped;
            bool started;
            SocketEndpoint listenep;
            bool requireauthenticate;

            
            class cpollthread: public Thread
                
            {
                cserv *parent;
            public:
                cpollthread( cserv *_parent ) 
                : Thread("CService::cpollthread"), parent(_parent) 
                {
                }
                int run() 
                { 
                    while (parent->poll())
                        Sleep(1000);
                    return 1;
                }
            } pollthread;
            Owned<IRemoteFileServer> server;

        public:

            cserv(SocketEndpoint _listenep) 
                : listenep(_listenep),pollthread(this)
            {
                stopped = false;
                started = false;
            }

            virtual ~cserv()
            {
                stopped = true;
                if (started)
                    pollthread.join();
            }

            bool init()
            {
                PROGLOG(DAFS_SERVICE_DISPLAY_NAME " Initialized");
                started = true;
                pollthread.start();
                return true;
            }

            bool poll()
            {
                if (stopped||!running()) {
                    PROGLOG(DAFS_SERVICE_DISPLAY_NAME " Stopping");
                    if (server) {
                        server->stop();
                        server.clear();
                    }
                    return false;
                }
                return true;
            }

            void run()
            {
                // Get params from HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\DaFileSrv\Parameters
                
                int requireauthenticate=0;
                HKEY hkey;
                if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,
                                 "SYSTEM\\CurrentControlSet\\Services\\DaFileSrv\\Parameters",
                                 0,
                                 KEY_QUERY_VALUE,
                                 &hkey) == ERROR_SUCCESS) {
                    DWORD dwType = 0;
                    DWORD dwSize = sizeof(requireauthenticate);
                    RegQueryValueEx(hkey,
                                    "RequireAuthentication",
                                    NULL,
                                    &dwType,
                                    (BYTE*)&requireauthenticate,
                                    &dwSize);
                    RegCloseKey(hkey);
                }
                StringBuffer eps;
                if (listenep.isNull())
                    eps.append(listenep.port);
                else
                    listenep.getUrlStr(eps);
                enableDafsAuthentication(requireauthenticate!=0);
                PROGLOG("Opening "DAFS_SERVICE_DISPLAY_NAME" on %s", eps.str());
                const char * verstring = remoteServerVersionString();
                PROGLOG("Version: %s", verstring);
                PROGLOG("Authentication:%s required",requireauthenticate?"":" not");
                PROGLOG(DAFS_SERVICE_DISPLAY_NAME " Running");
                server.setown(createRemoteFileServer());
                try {
                    server->run(listenep);
                }
                catch (IException *e) {
                    EXCLOG(e,DAFS_SERVICE_NAME);
                    e->Release();
                }
                PROGLOG(DAFS_SERVICE_DISPLAY_NAME " Stopped");
                stopped = true;
            }
        } service(listenep);
        service.start();
        return 0;
#else
        int ret = initDaemon();
        if (ret)
            return ret;
#endif
    }
    {
        Owned<IComponentLogFileCreator> lf = createComponentLogFileCreator(logDir.str(), "DAFILESRV");
        lf->setCreateAliasFile(false);
        lf->setMaxDetail(TopDetail);
        lf->beginLogging();
    }
    const char * verstring = remoteServerVersionString();
    StringBuffer eps;
    if (listenep.isNull())
        eps.append(listenep.port);
    else
        listenep.getUrlStr(eps);
    enableDafsAuthentication(requireauthenticate);
    PROGLOG("Opening Dali File Server on %s", eps.str());
    PROGLOG("Version: %s", verstring);
    PROGLOG("Authentication:%s required",requireauthenticate?"":" not");
    startPerformanceMonitor(10*60*1000, PerfMonStandard);
    server.setown(createRemoteFileServer());
    writeSentinelFile(sentinelFile);
    try {
        server->run(listenep);
    }
    catch (IException *e) {
        EXCLOG(e,"DAFILESRV");
        e->Release();
    }
    if (server)
        server->stop();
    server.clear();
    PROGLOG("Stopped Dali File Server");

    return 0;
}