summaryrefslogtreecommitdiff
path: root/src/mongo/util/ntservice.h
diff options
context:
space:
mode:
authorTad Marshall <tad@10gen.com>2012-02-27 15:17:16 -0500
committerTad Marshall <tad@10gen.com>2012-02-27 15:17:16 -0500
commit76427cd8a7f21210e0b41b0382ce05e05f092245 (patch)
tree31bfe6fefd56d20ec544ca49199ddb83eb80151d /src/mongo/util/ntservice.h
parentd1de28e30396b4f7489f2b9513e979448729d29c (diff)
downloadmongo-76427cd8a7f21210e0b41b0382ce05e05f092245.tar.gz
SERVER-1589 add Windows Service support to mongos.exe
Make mongos use the ntservice.cpp code already used by mongod to install a Windows service and to run as one. Change some text and move the definitions of default strings so the code can be shared. Restructure startup code in mongos slightly to separate command line parsing from runtime validation of the operating environment. Log operational states well in both mongod and mongos so that it is clear from the logs when the programs are running as services. Fix awful attempt at converting 8-bit text into 16-bit Unicode that was sign-extending characters in the range of 0x80 to 0xFF. Log the startup parameters in mongos that way that mongod does it, but don't log actual servicePassword strings in either program. Disallow the --upgrade flag from being used with service installation or operation in mongos and make this a general facility that can be used to disallow any option in either program. Add some comments to help future coders understand how this service business works in the code. Make the mongos startup code and output more similar to mongod to make maintenance easier and the user experience better. Disambiguate the flavors of exceptions we trap in mongos.
Diffstat (limited to 'src/mongo/util/ntservice.h')
-rw-r--r--src/mongo/util/ntservice.h26
1 files changed, 24 insertions, 2 deletions
diff --git a/src/mongo/util/ntservice.h b/src/mongo/util/ntservice.h
index 89b75846ad5..4492c317e27 100644
--- a/src/mongo/util/ntservice.h
+++ b/src/mongo/util/ntservice.h
@@ -23,15 +23,37 @@
namespace mongo {
+ struct ntServiceDefaultStrings {
+ const wchar_t* serviceName;
+ const wchar_t* displayName;
+ const wchar_t* serviceDescription;
+ };
+
typedef bool ( *ServiceCallback )( void );
- bool serviceParamsCheck( boost::program_options::variables_map& params, const std::string dbpath, int argc, char* argv[] );
+ bool serviceParamsCheck(
+ boost::program_options::variables_map& params,
+ const std::string dbpath,
+ const ntServiceDefaultStrings& defaultStrings,
+ const vector<string>& disallowedOptions,
+ int argc,
+ char* argv[]
+ );
class ServiceController {
public:
ServiceController();
virtual ~ServiceController() {}
- static bool installService( const std::wstring& serviceName, const std::wstring& displayName, const std::wstring& serviceDesc, const std::wstring& serviceUser, const std::wstring& servicePassword, const std::string dbpath, int argc, char* argv[] );
+ static bool installService(
+ const std::wstring& serviceName,
+ const std::wstring& displayName,
+ const std::wstring& serviceDesc,
+ const std::wstring& serviceUser,
+ const std::wstring& servicePassword,
+ const std::string dbpath,
+ int argc,
+ char* argv[]
+ );
static bool removeService( const std::wstring& serviceName );
static bool startService( const std::wstring& serviceName, ServiceCallback startService );
static bool reportStatus( DWORD reportState, DWORD waitHint = 0 );