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

 1 kumpf 1.2 //%2006////////////////////////////////////////////////////////////////////////
 2           //
 3           // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
 4           // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
 5           // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
 6           // IBM Corp.; EMC Corporation, The Open Group.
 7           // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
 8           // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
 9           // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
10           // EMC Corporation; VERITAS Software Corporation; The Open Group.
11           // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
12           // EMC Corporation; Symantec Corporation; The Open Group.
13           //
14           // Permission is hereby granted, free of charge, to any person obtaining a copy
15           // of this software and associated documentation files (the "Software"), to
16           // deal in the Software without restriction, including without limitation the
17           // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
18           // sell copies of the Software, and to permit persons to whom the Software is
19           // furnished to do so, subject to the following conditions:
20           // 
21           // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
22 kumpf 1.2 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
23           // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
24           // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
25           // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
26           // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
27           // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28           // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29           //
30           //==============================================================================
31           //
32           //%/////////////////////////////////////////////////////////////////////////////
33           
34           #include <Pegasus/Common/Config.h>
35           #include <Pegasus/Common/Constants.h>
36 kumpf 1.3 #include <Pegasus/Common/PegasusVersion.h>
37 kumpf 1.2 #include <Service/ServerRunStatus.h>
38           #include <Service/ServerShutdownClient.h>
39           
40           #ifdef PEGASUS_ENABLE_PRIVILEGE_SEPARATION
41           # define PEGASUS_PROCESS_NAME "cimservermain"
42           #else
43           # define PEGASUS_PROCESS_NAME "cimserver"
44           #endif
45           
46           PEGASUS_USING_PEGASUS;
47           PEGASUS_USING_STD;
48           
49           ServerRunStatus _serverRunStatus(
50               PEGASUS_PROCESS_NAME, PEGASUS_CIMSERVER_START_FILE);
51           
52           int main(int argc, char** argv)
53           {
54               MessageLoader::_useProcessLocale = true;
55               MessageLoader::setPegasusMsgHomeRelative(argv[0]);
56           
57               // Check arguments.
58 kumpf 1.2 
59               if (argc != 2)
60               {
61                   fprintf(stderr, "Usage: %s shutdown-timeout-in-seconds\n", argv[0]);
62                   fprintf(stderr,
63                       "%s is an internal program.  Please do not invoke it directly.\n",
64                       argv[0]);
65                   exit(1);
66               }
67           
68               // Extract timeout argument.
69           
70               char* end;
71               Uint32 timeout = (Uint32)strtoul(argv[1], &end, 0);
72           
73               if (*end != '\0' || timeout == 0)
74               {
75                   fprintf(stderr,
76                       "%s: bad timeout argument: \"%s\"\n", argv[0], argv[1]);
77                   exit(1);
78               }
79 kumpf 1.2 
80               // Shutdown.
81           
82               try
83               {
84                   ServerShutdownClient serverShutdownClient(&_serverRunStatus);
85                   serverShutdownClient.shutdown(timeout);
86           
87                   MessageLoaderParms parms(
88                       "src.Server.cimserver.SERVER_STOPPED",
89                       "CIM Server stopped.");
90                   cout << MessageLoader::getMessage(parms) << endl;
91               }
92               catch (Exception& e)
93               {
94                   cout << e.getMessage() << endl;
95                   exit(1);
96               }
97           
98               return 0;
99           }

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2