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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2