PageRenderTime 55ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/src/mongo/util/ntservice.h

https://gitlab.com/0072016/0072016-ApplePayDevice-
C Header | 103 lines | 31 code | 17 blank | 55 comment | 0 complexity | b117d90689908f4c91ad7973f33536ac MD5 | raw file
  1. /* Copyright 2009 10gen Inc.
  2. *
  3. * This program is free software: you can redistribute it and/or modify
  4. * it under the terms of the GNU Affero General Public License, version 3,
  5. * as published by the Free Software Foundation.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU Affero General Public License for more details.
  11. *
  12. * You should have received a copy of the GNU Affero General Public License
  13. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  14. *
  15. * As a special exception, the copyright holders give permission to link the
  16. * code of portions of this program with the OpenSSL library under certain
  17. * conditions as described in each individual source file and distribute
  18. * linked combinations including the program with the OpenSSL library. You
  19. * must comply with the GNU Affero General Public License in all respects
  20. * for all of the code used other than as permitted herein. If you modify
  21. * file(s) with this exception, you may extend this exception to your
  22. * version of the file(s), but you are not obligated to do so. If you do not
  23. * wish to do so, delete this exception statement from your version. If you
  24. * delete this exception statement from all source files in the program,
  25. * then also delete it in the license file.
  26. */
  27. /**
  28. * The ntservice namespace provides minimal support for running mongo servers as NT services.
  29. *
  30. * TODO: ntservice should only provide implementation for a more general server process
  31. * startup/shutdown/management interface.
  32. */
  33. #pragma once
  34. #ifdef _WIN32
  35. #include <string>
  36. #include <vector>
  37. #include "mongo/platform/compiler.h"
  38. #include "mongo/util/exit_code.h"
  39. namespace mongo {
  40. namespace optionenvironment {
  41. class OptionSection;
  42. class Environment;
  43. } // namespace optionenvironment
  44. namespace moe = mongo::optionenvironment;
  45. namespace ntservice {
  46. struct NtServiceDefaultStrings {
  47. const wchar_t* serviceName;
  48. const wchar_t* displayName;
  49. const wchar_t* serviceDescription;
  50. };
  51. typedef ExitCode (*ServiceCallback)(void);
  52. /**
  53. * Configure the service.
  54. *
  55. * Also performs service installation and removal.
  56. *
  57. * This function calls _exit() with an error if bad parameters are passed in. If
  58. * the parameters specify that the service should be installed, removed, etc, performs that
  59. * operation and exits.
  60. *
  61. * If this function returns to the caller, the caller should either call startService, or run
  62. * the service as a regular process, depending on the return value of shouldStartService().
  63. */
  64. void configureService(ServiceCallback serviceCallback,
  65. const moe::Environment& params,
  66. const NtServiceDefaultStrings& defaultStrings,
  67. const std::vector<std::string>& disallowedOptions,
  68. const std::vector<std::string>& argv);
  69. bool shouldStartService();
  70. /**
  71. * Construct an argv array that Windows should use to start mongod/mongos as a service
  72. * if mongo was started with "inputArgv", which is assumed to be an argument vector that
  73. * dictates that Windows should install mongo as a service.
  74. *
  75. * The result is suitable for passing to mongo::constructUtf8WindowsCommandLine() to construct
  76. * a properly quoted command line string.
  77. */
  78. std::vector<std::string> constructServiceArgv(const std::vector<std::string>& inputArgv);
  79. /**
  80. * Start the service. Never returns.
  81. */
  82. MONGO_COMPILER_NORETURN void startService();
  83. bool reportStatus(DWORD reportState, DWORD waitHint = 0, DWORD exitCode = 0);
  84. } // namespace ntservice
  85. } // namespace mongo
  86. #endif // defined(_WIN32)