(file) Return to ServerProcessWindows.cpp CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Service

  1 martin 1.13 //%LICENSE////////////////////////////////////////////////////////////////
  2 martin 1.14 //
  3 martin 1.13 // Licensed to The Open Group (TOG) under one or more contributor license
  4             // agreements.  Refer to the OpenPegasusNOTICE.txt file distributed with
  5             // this work for additional information regarding copyright ownership.
  6             // Each contributor licenses this file to you under the OpenPegasus Open
  7             // Source License; you may not use this file except in compliance with the
  8             // License.
  9 martin 1.14 //
 10 martin 1.13 // Permission is hereby granted, free of charge, to any person obtaining a
 11             // copy of this software and associated documentation files (the "Software"),
 12             // to deal in the Software without restriction, including without limitation
 13             // the rights to use, copy, modify, merge, publish, distribute, sublicense,
 14             // and/or sell copies of the Software, and to permit persons to whom the
 15             // Software is furnished to do so, subject to the following conditions:
 16 martin 1.14 //
 17 martin 1.13 // The above copyright notice and this permission notice shall be included
 18             // in all copies or substantial portions of the Software.
 19 martin 1.14 //
 20 martin 1.13 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 21 martin 1.14 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 22 martin 1.13 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 23             // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
 24             // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 25             // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 26             // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 27 martin 1.14 //
 28 martin 1.13 //////////////////////////////////////////////////////////////////////////
 29 h.sterling 1.1  //
 30                 //%/////////////////////////////////////////////////////////////////////////////
 31                 
 32                 #include <windows.h>
 33                 #include <process.h>    /* _beginthread, _endthread */
 34                 #include <tchar.h>
 35                 #include <direct.h>
 36 kumpf      1.7  #include <Pegasus/Common/MessageLoader.h>
 37                 #include <Pegasus/Common/Thread.h>
 38 kavita.gupta 1.16 #include <Pegasus/Common/Exception.h>
 39 h.sterling   1.1  #include <Pegasus/Server/CIMServer.h>
 40 kumpf        1.8  #include <Service/ServerRunStatus.h>
 41 h.sterling   1.1  
 42                   #include "Service.cpp"
 43                   
 44                   PEGASUS_USING_PEGASUS;
 45                   PEGASUS_USING_STD;
 46                   
 47                   //-------------------------------------------------------------------------
 48                   // GLOBALS
 49                   //-------------------------------------------------------------------------
 50                   static Mutex _cimserverLock;
 51                   static ServerProcess* _server_proc = 0;
 52                   static bool _shutdown = false;
 53                   static Service pegasus_service;
 54                   static HANDLE pegasus_service_event = NULL;
 55 kumpf        1.10 static LPCSTR g_cimservice_key =
 56                       TEXT("SYSTEM\\CurrentControlSet\\Services\\%s");
 57 h.sterling   1.1  static LPCSTR g_cimservice_home = TEXT("home");
 58                   static int g_argc = 0;
 59                   static char **g_argv = 0;
 60                   
 61                   //  Constants representing the command line options.
 62                   static const char OPTION_INSTALL[] = "install";
 63                   static const char OPTION_REMOVE[]  = "remove";
 64                   static const char OPTION_START[]   = "start";
 65                   static const char OPTION_STOP[]    = "stop";
 66                   
 67                   //-------------------------------------------------------------------------
 68                   // PROTOTYPES
 69                   //-------------------------------------------------------------------------
 70                   int cimserver_windows_main(int flag, int argc, char **argv);
 71                   static bool _getRegInfo(const char *lpchKeyword, char *lpchRetValue);
 72                   static bool _setRegInfo(const char *lpchKeyword, const char *lpchValue);
 73                   
 74                   //-------------------------------------------------------------------------
 75                   // NO-OPs for windows platform
 76                   //-------------------------------------------------------------------------
 77 kumpf        1.10 int ServerProcess::cimserver_fork() { return(0); }
 78 h.sterling   1.1  void ServerProcess::notify_parent(int id) { return; }
 79                   void cimserver_exitRC(int rc) {}
 80 kumpf        1.10 int ServerProcess::cimserver_initialize() { return 0; }
 81                   int ServerProcess::cimserver_wait() { return 0; }
 82 h.sterling   1.1  
 83                   
 84                   //-------------------------------------------------------------------------
 85                   // Helper for platform specific handling
 86                   //-------------------------------------------------------------------------
 87                   
 88                   ServerProcess::ServerProcess()
 89                   {
 90 kumpf        1.10     // Be sure to call cimserver_set_process right after instantiating this in
 91                       // order for everything to work
 92 h.sterling   1.1  }
 93                   
 94                   ServerProcess::~ServerProcess()
 95                   {
 96                   }
 97                   
 98                   void ServerProcess::cimserver_set_process(void* p)
 99                   {
100 kumpf        1.10     AutoMutex am(_cimserverLock);
101 h.sterling   1.1      _server_proc = static_cast<ServerProcess *>(p);
102 kumpf        1.10     if (_server_proc && _shutdown)
103 h.sterling   1.1          _server_proc->cimserver_stop();
104                   
105                       pegasus_service = Service(getProcessName());
106                   }
107                   
108                   void signal_shutdown()
109                   {
110 kumpf        1.10     AutoMutex am(_cimserverLock);
111 h.sterling   1.1      _shutdown = true;
112 kumpf        1.10     if (_server_proc)
113 kumpf        1.15         _server_proc->cimserver_stop();
114 h.sterling   1.1  }
115                   
116                   //-------------------------------------------------------------------------
117                   // Run main server asynchronously
118                   //-------------------------------------------------------------------------
119 kumpf        1.10 static unsigned __stdcall cimserver_windows_thread(void* parm)
120 h.sterling   1.1  {
121                       int argc = 0;
122 kumpf        1.10     int rc = _server_proc->cimserver_run(g_argc, g_argv, false, false);
123 h.sterling   1.1      SetEvent(pegasus_service_event);
124 kumpf        1.10     _endthreadex(rc);
125 h.sterling   1.1      return rc;
126                   }
127                   
128                   //-------------------------------------------------------------------------
129 kumpf        1.15 //  Windows NT Service Control Code
130 h.sterling   1.1  //-------------------------------------------------------------------------
131                   
132                   //-------------------------------------------------------------------------
133 kumpf        1.15 // START/STOP handler
134 h.sterling   1.1  //-------------------------------------------------------------------------
135                   int cimserver_windows_main(int flag, int argc, char *argv[])
136                   {
137 kumpf        1.10     switch(flag)
138 h.sterling   1.1      {
139                       case Service::STARTUP_FLAG:
140                       {
141                           //
142                           // Start up main run in a separate thread and wait for it to finish.
143                           //
144                   
145                           unsigned threadid = 0;
146                           g_argc = argc;
147                           g_argv = argv;
148 kumpf        1.10         HANDLE hThread = (HANDLE)_beginthreadex(
149                               NULL, 0, cimserver_windows_thread, NULL, 0, &threadid);
150                           if (hThread == NULL)
151 h.sterling   1.1              return 1;
152                   
153 kumpf        1.10         WaitForSingleObject(pegasus_service_event, INFINITE);
154 h.sterling   1.1  
155                           //
156                           // Shutdown the cimserver.
157                           //
158                   
159                           signal_shutdown();
160                   
161                           //
162                           // Make sure we upate the SCM that our stop is pending.
163                           // Wait for the main run thread to exit.
164                           //
165                   
166                           DWORD dwCheckPoint = 1; // service code should have already started at 0
167                   
168 kumpf        1.10         while (WaitForSingleObject(hThread, 3000) == WAIT_TIMEOUT)
169 h.sterling   1.1          {
170 kumpf        1.15             pegasus_service.report_status(
171 kumpf        1.10                 SERVICE_STOP_PENDING, NO_ERROR, dwCheckPoint++, 5000);
172 h.sterling   1.1          }
173                   
174 kumpf        1.10         CloseHandle(hThread);
175 h.sterling   1.1          break;
176                       }
177                       case Service::SHUTDOWN_FLAG:
178                           SetEvent(pegasus_service_event);
179                           break;
180                   
181                       default:
182                           break;
183                       }
184                   
185                       return 0;
186                   }
187                   
188                   
189                   //-------------------------------------------------------------------------
190                   // INSTALL
191                   //-------------------------------------------------------------------------
192                   bool cimserver_install_nt_service(char *service_name)
193                   {
194 kumpf        1.10     Service::ReturnCode status = Service::SERVICE_RETURN_SUCCESS;
195                       char filename[_MAX_PATH] = {0};
196                       char displayname[_MAX_PATH] = {0};
197                       char descriptionname[_MAX_PATH] = {0};
198                   
199                       // If service name is specified, override default
200                       if (service_name == NULL)
201                       {
202                           strcpy(displayname, _server_proc->getExtendedName());
203                       }
204                       else
205                       {
206                           pegasus_service.SetServiceName(service_name);
207                           sprintf(displayname, "%s - %s",
208                               _server_proc->getExtendedName(),
209                               service_name);
210                       }
211                   
212                       strcpy(descriptionname, _server_proc->getDescription());
213                   
214                       if (0 != GetModuleFileName(NULL, filename, sizeof(filename)))
215 kumpf        1.10     {
216                           status =
217                               pegasus_service.Install(displayname, descriptionname, filename);
218                   
219                           // Upon success, set home in registry
220                           if (status == Service::SERVICE_RETURN_SUCCESS)
221                           {
222                               char pegasus_homepath[_MAX_PATH];
223                               System::extract_file_path(filename, pegasus_homepath);
224                               pegasus_homepath[strlen(pegasus_homepath)-1] = '\0';
225                               strcpy(filename, pegasus_homepath);
226                               System::extract_file_path(filename, pegasus_homepath);
227                               pegasus_homepath[strlen(pegasus_homepath)-1] = '\0';
228                               _setRegInfo(g_cimservice_home, pegasus_homepath);
229                           }
230                       }
231                       else
232                       {
233                           status = (Service::ReturnCode) GetLastError();
234                       }
235                   
236 kumpf        1.10     return (status == Service::SERVICE_RETURN_SUCCESS);
237 h.sterling   1.1  }
238                   
239                   //-------------------------------------------------------------------------
240                   // REMOVE
241                   //-------------------------------------------------------------------------
242 kumpf        1.10 bool cimserver_remove_nt_service(char* service_name)
243 h.sterling   1.1  {
244 kumpf        1.10     Service::ReturnCode status = Service::SERVICE_RETURN_SUCCESS;
245 h.sterling   1.1  
246 kumpf        1.10     // If service name is specified, override default
247                       if (service_name != NULL)
248 h.sterling   1.1      {
249 kumpf        1.10         pegasus_service.SetServiceName(service_name);
250 h.sterling   1.1      }
251                   
252 kumpf        1.10     status = pegasus_service.Remove();
253 h.sterling   1.1  
254 kumpf        1.10     return (status == Service::SERVICE_RETURN_SUCCESS);
255 h.sterling   1.1  }
256                   
257                   //-------------------------------------------------------------------------
258                   // START
259                   //-------------------------------------------------------------------------
260 kumpf        1.10 bool cimserver_start_nt_service(
261                       char* service_name,
262                       int num_args,
263                       char** service_args)
264 h.sterling   1.1  {
265 kumpf        1.10     Service::ReturnCode status = Service::SERVICE_RETURN_SUCCESS;
266 h.sterling   1.1  
267 kumpf        1.10     // If service name is specified, override default
268                       if (service_name != NULL)
269 h.sterling   1.1      {
270 kumpf        1.10         pegasus_service.SetServiceName(service_name);
271 h.sterling   1.1      }
272                   
273 kumpf        1.10     if (num_args > 0 && service_args != NULL)
274                       {
275                           pegasus_service.SetServiceArgs(num_args, service_args);
276                       }
277 h.sterling   1.1  
278 kumpf        1.10     status = pegasus_service.Start(5);
279 h.sterling   1.1  
280 kumpf        1.10     return (status == Service::SERVICE_RETURN_SUCCESS);
281 h.sterling   1.1  }
282                   
283                   //-------------------------------------------------------------------------
284                   // STOP
285                   //-------------------------------------------------------------------------
286 kumpf        1.10 bool cimserver_stop_nt_service(char* service_name)
287 h.sterling   1.1  {
288 kumpf        1.10     Service::ReturnCode status = Service::SERVICE_RETURN_SUCCESS;
289 h.sterling   1.1  
290 kumpf        1.10     // If service name is specified, override default
291                       if (service_name != NULL)
292 h.sterling   1.1      {
293 kumpf        1.10         pegasus_service.SetServiceName(service_name);
294 h.sterling   1.1      }
295                   
296 kumpf        1.10     status = pegasus_service.Stop(5);
297 h.sterling   1.1  
298 kumpf        1.10     return (status == Service::SERVICE_RETURN_SUCCESS);
299 h.sterling   1.1  }
300                   
301                   //-------------------------------------------------------------------------
302                   // HELPER Utilities
303                   //-------------------------------------------------------------------------
304 kumpf        1.10 static bool _getRegInfo(
305                       const char* lpchKeyword,
306                       char* lpchRetValue)
307 h.sterling   1.1  {
308 kumpf        1.10     HKEY hKey;
309                       DWORD dw = _MAX_PATH;
310                       char subKey[_MAX_PATH] = {0};
311                   
312                       sprintf(subKey, g_cimservice_key, pegasus_service.GetServiceName());
313 h.sterling   1.1  
314 kumpf        1.10     if ((RegOpenKeyEx(
315                                HKEY_LOCAL_MACHINE,
316                                subKey,
317                                0,
318                                KEY_READ,
319                                &hKey)) != ERROR_SUCCESS)
320 h.sterling   1.1      {
321 kumpf        1.10         return false;
322 h.sterling   1.1      }
323                   
324 kumpf        1.10     if ((RegQueryValueEx(
325                                hKey,
326                                lpchKeyword,
327                                NULL,
328                                NULL,
329                                (LPBYTE)lpchRetValue,
330                                &dw)) != ERROR_SUCCESS)
331 h.sterling   1.1      {
332 kumpf        1.10         RegCloseKey(hKey);
333                           return false;
334 h.sterling   1.1      }
335                   
336 kumpf        1.10     RegCloseKey(hKey);
337 h.sterling   1.1  
338 kumpf        1.10     return true;
339 h.sterling   1.1  }
340                   
341 kumpf        1.10 static bool _setRegInfo(
342                       const char* lpchKeyword,
343                       const char* lpchValue)
344 h.sterling   1.1  {
345 kumpf        1.10     HKEY hKey;
346                       DWORD dw = _MAX_PATH;
347                       char home_key[_MAX_PATH] = {0};
348                       char subKey[_MAX_PATH] = {0};
349 h.sterling   1.1  
350 kumpf        1.10     if (lpchKeyword == NULL || lpchValue == NULL)
351                           return false;
352 h.sterling   1.1  
353 kumpf        1.10     sprintf(subKey, g_cimservice_key, pegasus_service.GetServiceName());
354 h.sterling   1.1  
355 kumpf        1.10     if ((RegCreateKeyEx(
356                                HKEY_LOCAL_MACHINE,
357                                subKey,
358                                0,
359                                NULL,
360                                0,
361                                KEY_ALL_ACCESS,
362                                NULL,
363                                &hKey,
364                                NULL) != ERROR_SUCCESS))
365 h.sterling   1.1      {
366 kumpf        1.10         return false;
367 h.sterling   1.1      }
368                   
369 kumpf        1.10     if ((RegSetValueEx(
370                                hKey,
371                                lpchKeyword,
372                                0,
373                                REG_SZ,
374                                (CONST BYTE *)lpchValue,
375                                (DWORD)(strlen(lpchValue)+1))) != ERROR_SUCCESS)
376 h.sterling   1.1      {
377 kumpf        1.10         RegCloseKey(hKey);
378                           return false;
379 h.sterling   1.1      }
380                   
381 kumpf        1.10     RegCloseKey(hKey);
382 h.sterling   1.1  
383 kumpf        1.10     return true;
384 h.sterling   1.1  }
385                   
386                   //void ServerProcess::setHome(const String& home)
387 kumpf        1.10 String ServerProcess::getHome()
388 h.sterling   1.1  {
389 kumpf        1.7      String home;
390 h.sterling   1.1  
391 kumpf        1.10     // Determine the absolute path to the running program
392                       char exe_pathname[_MAX_PATH] = {0};
393                       char home_pathname[_MAX_PATH] = {0};
394                       if (0 != GetModuleFileName(NULL, exe_pathname, sizeof(exe_pathname)))
395                       {
396                           // Pegasus home search rules:
397                           // - look in registry (if set)
398                           // - if not found, look in PEGASUS_HOME (if set)
399                           // - if not found, use exe directory minus one level
400                   
401                           bool found_reg = _getRegInfo("home", home_pathname);
402                           if (found_reg)
403                           {
404                               // Make sure home matches
405                               String current_home(home_pathname);
406                               String current_exe(exe_pathname);
407                               current_home.toLower();
408                               current_exe.toLower();
409                   
410                               Uint32 pos = current_exe.find(current_home);
411                               if (pos != PEG_NOT_FOUND)
412 kumpf        1.10             {
413                                   home = home_pathname;
414                               }
415                               else
416                               {
417                                   found_reg = false;
418                               }
419                           }
420                           if (found_reg == false)
421                           {
422                               const char* tmp = getenv("PEGASUS_HOME");
423                               if (tmp)
424                               {
425                                   home = tmp;
426                               }
427                               else
428                               {
429                                   // ASSUMPTION: At a minimum, the cimserver program is running
430                                   // from a "bin" directory
431                                   home = FileSystem::extractFilePath(exe_pathname);
432                                   home.remove(home.size()-1, 1);
433 kumpf        1.10                 home = FileSystem::extractFilePath(home);
434                                   home.remove(home.size()-1, 1);
435                               }
436                           }
437                       }
438 h.sterling   1.1      return home;
439                   }
440                   
441                   //
442                   // Our console control handler
443                   //
444                   
445 kumpf        1.10 static BOOL WINAPI ControlHandler(DWORD dwCtrlType)
446 h.sterling   1.1  {
447 kumpf        1.10     switch (dwCtrlType)
448 h.sterling   1.1      {
449                       case CTRL_BREAK_EVENT:  // use Ctrl+C or Ctrl+Break to simulate
450                       case CTRL_C_EVENT:      // SERVICE_CONTROL_STOP in debug mode
451                       {
452                           signal_shutdown();
453                           return TRUE;
454                       }
455                       }
456                       return FALSE;
457                   }
458                   
459                   //
460                   // Platform specific run
461                   //
462                   
463 kumpf        1.4  int ServerProcess::platform_run(
464                       int argc,
465                       char** argv,
466                       Boolean shutdownOption,
467                       Boolean debugOutputOption)
468 h.sterling   1.1  {
469                       //
470                       // Check for my command line options
471                       //
472                   
473 kumpf        1.10     for (int i = 1; i < argc; )
474 h.sterling   1.1      {
475                           const char* arg = argv[i];
476                   
477                           // Check for -option
478                           if (*arg == '-')
479                           {
480                               // Get the option
481                               const char* option = arg + 1;
482                   
483                               if (strcmp(option, OPTION_INSTALL) == 0)
484                               {
485                                   //
486                                   // Install as a NT service
487                                   //
488                                   char *opt_arg = NULL;
489                                   if (i+1 < argc)
490                                   {
491                                       opt_arg = argv[i+1];
492                   
493                                   }
494 kumpf        1.10                 if (cimserver_install_nt_service(opt_arg))
495 h.sterling   1.1                  {
496                                       //l10n
497                                       //cout << "\nPegasus installed as NT Service";
498                                       MessageLoaderParms parms(
499                                           "src.Server.cimserver.INSTALLED_NT_SERVICE",
500                                           "\nPegasus installed as a Windows service");
501                                       cout << MessageLoader::getMessage(parms) << endl;
502                                       exit(0);
503                                   }
504                                   else
505                                   {
506                                       exit(0);
507                                   }
508                               }
509                               else if (strcmp(option, OPTION_REMOVE) == 0)
510                               {
511                                   //
512                                   // Remove Pegasus as an NT service
513                                   //
514                                   char *opt_arg = NULL;
515                                   if (i+1 < argc)
516 h.sterling   1.1                  {
517 kumpf        1.10                     opt_arg = argv[i+1];
518 h.sterling   1.1                  }
519 kumpf        1.10                 if (cimserver_remove_nt_service(opt_arg))
520 h.sterling   1.1                  {
521                                       //l10n
522                                       //cout << "\nPegasus removed as NT Service";
523                                       MessageLoaderParms parms(
524                                           "src.Server.cimserver.REMOVED_NT_SERVICE",
525                                           "\nPegasus removed as a Windows service");
526                                       cout << MessageLoader::getMessage(parms) << endl;
527                                       exit(0);
528                                   }
529                                   else
530                                   {
531                                       exit(0);
532                                   }
533                   
534                               }
535                               else if (strcmp(option, OPTION_START) == 0)
536                               {
537                                   //
538                                   // Start as a NT service
539                                   //
540                                   char *opt_arg = NULL;
541 h.sterling   1.1                  int num_args = 0;
542                                   if (i+1 < argc)
543                                   {
544 kumpf        1.10                     opt_arg = argv[i+1];
545 h.sterling   1.1                      num_args = argc - 3;
546                                   }
547                                   else
548                                   {
549                                       num_args = argc - 2;
550                                   }
551                   
552                                   char **service_args = &argv[1];
553 kumpf        1.10                 if (cimserver_start_nt_service(opt_arg, num_args, service_args))
554 h.sterling   1.1                  {
555                                       MessageLoaderParms parms(
556                                           "src.Server.cimserver.STARTED_NT_SERVICE",
557                                           "\nPegasus started as a Windows service");
558                                       cout << MessageLoader::getMessage(parms) << endl;
559                                       exit(0);
560                                   }
561                                   else
562                                   {
563                                       exit(0);
564                                   }
565                               }
566                               else if (strcmp(option, OPTION_STOP) == 0)
567                               {
568                                   //
569                                   // Stop as a NT service
570                                   //
571                                   char *opt_arg = NULL;
572                                   if (i+1 < argc)
573                                   {
574 kumpf        1.10                     opt_arg = argv[i+1];
575 h.sterling   1.1                  }
576 kumpf        1.10                 if (cimserver_stop_nt_service(opt_arg))
577 h.sterling   1.1                  {
578                                       MessageLoaderParms parms(
579                                           "src.Server.cimserver.STOPPED_NT_SERVICE",
580                                           "\nPegasus stopped as a Windows service");
581                                       cout << MessageLoader::getMessage(parms) << endl;
582                                       exit(0);
583                                   }
584                                   else
585                                   {
586                                       exit(0);
587                                   }
588                               }
589                               else
590                                   i++;
591                           }
592                           else
593                               i++;
594                       }
595                   
596                       //
597                       // Signal ourself as running
598 h.sterling   1.1      //
599                   
600 kumpf        1.8      // NOTE: This object must persist for the life of the server process
601 kumpf        1.11     ServerRunStatus serverRunStatus(getProcessName(), 0);
602 kumpf        1.8  
603                       if (!shutdownOption)
604                       {
605 dave.sudlik  1.9          serverRunStatus.setServerRunning();
606 kumpf        1.8      }
607 h.sterling   1.1  
608                       //
609                       // Check if already running
610                       //
611                       // Hmm, when starting as a service, should we do this here (before
612                       // starting the control dispatcher)?  If we do then the SCM reports
613 kumpf        1.10     // a dumb message to the user.  If we don't, and it in the serviceProc
614 h.sterling   1.1      // then the service will start up then die silently.
615                       //
616                   
617 kumpf        1.8      if (!shutdownOption && serverRunStatus.isServerRunning())
618 h.sterling   1.1      {
619                           MessageLoaderParms parms(
620                               "src.Server.cimserver.UNABLE_TO_START_SERVER_ALREADY_RUNNING",
621 kumpf        1.10             "Unable to start CIMServer.\nCIMServer is already running.");
622 kumpf        1.12         Logger::put_l(
623 h.sterling   1.1              Logger::ERROR_LOG, "CIMServer", Logger::SEVERE,
624 kumpf        1.12             parms);
625 kumpf        1.10         PEGASUS_STD(cerr) << MessageLoader::getMessage(parms) <<
626                               PEGASUS_STD(endl);
627 h.sterling   1.1          return 1;
628                       }
629                   
630                       //
631                       // Check if running from a console window. If so then just run
632                       // as a console process.
633                       //
634                   
635                       char console_title[ _MAX_PATH ] = {0};
636 kumpf        1.10     if (GetConsoleTitle(console_title, _MAX_PATH) > 0)
637 h.sterling   1.1      {
638 kumpf        1.10         SetConsoleCtrlHandler(ControlHandler, TRUE);
639 h.sterling   1.1  
640 kumpf        1.4          return cimserver_run(argc, argv, shutdownOption, debugOutputOption);
641 h.sterling   1.1      }
642                   
643                       //
644                       // Run as a service
645                       //
646                   
647 kumpf        1.10     pegasus_service_event = CreateEvent(NULL, FALSE, FALSE, NULL);
648 kavita.gupta 1.16     if (pegasus_service_event == NULL)
649                       {
650                           throw Exception(MessageLoaderParms(
651                               "src.Server.cimserver_windows.EVENT_CREATION_FAILED",
652                               "Event Creation Failed : $0.",
653                               PEGASUS_SYSTEM_ERRORMSG_NLS));
654                       }
655 h.sterling   1.1  
656                       Service::ReturnCode status;
657 kumpf        1.10     status = pegasus_service.Run(cimserver_windows_main);
658 h.sterling   1.1  
659 kumpf        1.10     if (status != Service::SERVICE_RETURN_SUCCESS)
660 h.sterling   1.1      {
661                           // todo: put into localized messages when messages unfreezes.
662                           Logger::put_l(
663                               Logger::ERROR_LOG, "CIMServer", Logger::SEVERE,
664 kumpf        1.12             MessageLoaderParms(
665                                   "src.Server.cimserver_windows.LISTENING_ON_HTTP_PORT",
666                                   "Error during service run: code = $0.",
667                                   status));
668 h.sterling   1.1          return 1;
669                       }
670                   
671                       return 0;
672                   }

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2