コード例 #1
0
/*
* CNTService::Run ()
* Worker loop for the service
*/
void CNTService::Run() {
    Log("Entering CNTService::Run\n");
    InitializeEnvironment();

    std::string command =   gServiceLauncherCommand ;
    command             +=  "status ";
    command             +=  gWorkingDirectory;

    Log ( "CNTService::Run Command = %s\n", command.c_str());

    char psBuffer [1024];
    while (1) {
        FILE   *pPipe;
        if( (pPipe = _popen( command.c_str(), "rt" )) != NULL ) {                    
            while (fgets(psBuffer, 1024, pPipe));
            Log( "[RUN] ==> %s\n", psBuffer);
            feof(pPipe);
            if (strstr (psBuffer, "stopped")) {
                Log( "[RUN] ==> Gemfire server aborted\n");
                break;
            } else {
                Log( "[RUN] ==> Sleeping now \n");
                Sleep(60000);
            }
        } else {
            Log( "[RUN] ==> _popen failed \n");
            break;
        }
    }    
    StopGemfireServer();
    Log("Exiting CNTService::Run\n");
}
コード例 #2
0
/**
* Overriding Windows Service Init Method. Used to initialize the service under the 
* Service Control Manager
*/
BOOL CNTService::Init () {
    Log("Entering CNTService::Init\n");
    InitializeEnvironment();
    StartGemfireServer(); 
    Log("Exiting CNTService::Init\n");
    return TRUE;
}
コード例 #3
0
ファイル: wccore.c プロジェクト: perusio/webclips-old
//Initializes the CLIPS Engine for the WebCLIPS environment
int Init(void)
{
	//Initialize the appropriate CLIPS Engine (Standard vs. Fuzzy)
	//	DLL Loaded here
	SetPrintWhileLoading(FALSE);
	InitializeEnvironment();
	return 0;
}
コード例 #4
0
ファイル: main.c プロジェクト: OS2World/DEV-LISP-Clips
int main(
  int argc,
  char *argv[])
  {
   InitializeEnvironment();   
   RerouteStdin(argc,argv);
   CommandLoop();
   return(-1);
  }
コード例 #5
0
int main (int argc, char *argv[]) {    
    InitializeEnvironment();

    if ( argv[1] && (strcmp( argv[1], "--servicemode")) == 0 ) {
        CNTService ntService(argv[2]);        
        int idx = 3;

        while ( argv[idx] ) {
            if (strstr( argv[idx], "-dir=" ) ) {
                gWorkingDirectory = argv[idx];                        
            }
            gParams += argv[idx];
            gParams += " ";
            idx++;
        }

        gServiceLauncherCommand = "\"" + gGemfireHome + "\\bin\\cacheserver.bat" + "\"" + " ";

        std::string::size_type foundPos = gWorkingDirectory.find_first_of("=", 0);
        gLogFilePath = gWorkingDirectory.substr(foundPos + 1, gWorkingDirectory.size() );       
        gLogFilePath += "\\GemfireSvcLauncher.log";

        ntService.StartService();
    }
    else if ( argc > 2 ) {
        // foreground mode
        ParseCommandLineArguments(argc, argv);    
        gLogFilePath = gWorkingDirectory + "\\GemfireSvcLauncher.log";
        setlocale (LC_ALL, "");

        CNTService ntService(gServiceName.c_str());

        if ( isInstall ) {        
            if (ntService.IsInstalled ()) {
                std::cout << gServiceName << " - Service is already installed " << std::endl;
                exit ( 0 );
            }
            if (ntService.Install ()) {
                std::cout << gServiceName << " - Service Installed " << std::endl;
            }
        }
    } else {
        Usage();
    }

    return 0;

}
コード例 #6
0
ファイル: CMultiSAP.cpp プロジェクト: hgl888/nashtest
//-------------------------------------------------------------------------
//  Initialize
//  configures D3D environment and creates composing thread
//-------------------------------------------------------------------------
HRESULT CMultiSAP::Initialize()
{
    HRESULT hr = CoInitialize(NULL);
    if (hr == S_FALSE)
        CoUninitialize();

    hr = InitializeEnvironment();
    if (SUCCEEDED(hr))
    {
        m_hThread = CreateThread(NULL, 0, ComposeThreadProc, this, 0, &m_dwThreadID);
        if (!m_hThread)
            hr = E_FAIL;
    }

    return hr;
}
コード例 #7
0
//-----------interface with outside functions-----------------------------------
bool EnvironmentROBARM::InitializeEnv(const char* sEnvFile)
{

	FILE* fCfg = fopen(sEnvFile, "r");
	if(fCfg == NULL)
	{
		printf("ERROR: unable to open %s\n", sEnvFile);
		exit(1);
	}
	ReadConfiguration(fCfg);

	//Initialize other parameters of the environment
	InitializeEnvConfig();

	//initialize Environment
	if(InitializeEnvironment() == false)
        return false;

	//pre-compute heuristics
	ComputeHeuristicValues();

	return true;
}
コード例 #8
0
ファイル: main.c プロジェクト: ivanprague90/hypnotoad
int main(int argc, char **argv) {
	   InitializeEnvironment();
       IncrementGCLocks();
       Load("src/main.clp");
       void * module = FindDefmodule("Hypnotoad");
       SetCurrentModule(module);

       zmq = zmq_init(1);
       pub = zmq_socket(zmq, ZMQ_PUB);
       zmq_bind(pub, "tcp://*:5554");

       void * sub = zmq_socket(zmq, ZMQ_SUB);
       zmq_bind(sub, "tcp://*:5555");
       zmq_setsockopt(sub, ZMQ_SUBSCRIBE, "", 0);

	   while (1) {
            char * msg, * topic;
            int topic_size;
            char * remote_filename;
		    zmq_msg_t request;

		    zmq_msg_init (&request);
		    zmq_recv (sub, &request, 0);
		    topic = zmq_msg_data (&request);
            topic_size = zmq_msg_size(&request);

            int fact = !strncmp(topic, "fact", 4);
            if (!fact) {
              remote_filename = (char *) malloc(topic_size + 1);
              strncpy(remote_filename, topic, topic_size);
            }

		    zmq_msg_close (&request);

		    zmq_msg_init (&request);
		    zmq_recv (sub, &request, 0);
		    msg = zmq_msg_data (&request);

            if (fact) {
              LoadFactsFromString(msg, zmq_msg_size(&request));
              Focus(module);
              Run(-1);
            } else {
              char * filename = tmpnam(0);

              /* dump file */
              FILE * f = fopen(filename,"w+");
              fwrite(msg, zmq_msg_size(&request), 1, f);
              fclose(f);

              char * fact = (char *) malloc(1024);
              sprintf(fact, "(remote-file \"%s\" \"%s\")\n",remote_filename,filename);

              /* load file mapping */
              Focus(module);
              LoadFactsFromString(fact, -1);

              Focus(module);
              Run(-1);

#if 0
              DATA_OBJECT res;
              Eval("(facts)",&res);
              fflush(0);
#endif              
              /* cleanup */
              free(fact);
              free(remote_filename);
              unlink(filename);
              free(filename);
            }
		    zmq_msg_close (&request);
	   }

       zmq_close(pub);
       zmq_close(sub);
       zmq_term(zmq);

       DecrementGCLocks();
}