1 martin 1.4 //%LICENSE////////////////////////////////////////////////////////////////
|
2 martin 1.5 //
|
3 martin 1.4 // 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.5 //
|
10 martin 1.4 // 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.5 //
|
17 martin 1.4 // The above copyright notice and this permission notice shall be included
18 // in all copies or substantial portions of the Software.
|
19 martin 1.5 //
|
20 martin 1.4 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
21 martin 1.5 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
22 martin 1.4 // 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.5 //
|
28 martin 1.4 //////////////////////////////////////////////////////////////////////////
|
29 kumpf 1.2 //
30 //%/////////////////////////////////////////////////////////////////////////////
31
32 #include <Pegasus/Common/Config.h>
33 #include <Pegasus/Common/Constants.h>
|
34 kumpf 1.3 #include <Pegasus/Common/PegasusVersion.h>
|
35 kumpf 1.2 #include <Service/ServerRunStatus.h>
36 #include <Service/ServerShutdownClient.h>
37
38 #ifdef PEGASUS_ENABLE_PRIVILEGE_SEPARATION
39 # define PEGASUS_PROCESS_NAME "cimservermain"
40 #else
41 # define PEGASUS_PROCESS_NAME "cimserver"
42 #endif
43
44 PEGASUS_USING_PEGASUS;
45 PEGASUS_USING_STD;
46
47 ServerRunStatus _serverRunStatus(
48 PEGASUS_PROCESS_NAME, PEGASUS_CIMSERVER_START_FILE);
49
50 int main(int argc, char** argv)
51 {
52 MessageLoader::_useProcessLocale = true;
53 MessageLoader::setPegasusMsgHomeRelative(argv[0]);
54
55 // Check arguments.
56 kumpf 1.2
57 if (argc != 2)
58 {
59 fprintf(stderr, "Usage: %s shutdown-timeout-in-seconds\n", argv[0]);
60 fprintf(stderr,
61 "%s is an internal program. Please do not invoke it directly.\n",
62 argv[0]);
63 exit(1);
64 }
65
66 // Extract timeout argument.
67
68 char* end;
69 Uint32 timeout = (Uint32)strtoul(argv[1], &end, 0);
70
71 if (*end != '\0' || timeout == 0)
72 {
73 fprintf(stderr,
74 "%s: bad timeout argument: \"%s\"\n", argv[0], argv[1]);
75 exit(1);
76 }
77 kumpf 1.2
78 // Shutdown.
79
80 try
81 {
82 ServerShutdownClient serverShutdownClient(&_serverRunStatus);
83 serverShutdownClient.shutdown(timeout);
84
85 MessageLoaderParms parms(
86 "src.Server.cimserver.SERVER_STOPPED",
87 "CIM Server stopped.");
88 cout << MessageLoader::getMessage(parms) << endl;
89 }
90 catch (Exception& e)
91 {
92 cout << e.getMessage() << endl;
93 exit(1);
94 }
95
96 return 0;
97 }
|