summaryrefslogtreecommitdiff
path: root/util/ntservice.h
diff options
context:
space:
mode:
authoralanw <alanwright.atex@googlemail.com>2009-06-04 18:26:15 +0800
committermongodb <mongodb@10gen.com>2009-06-04 20:55:33 +0800
commitc9c9dc5b03d78af082e8ba7da282261470e028bd (patch)
tree5cd31162a41d8d8200ca9bfad3c0719265ad363a /util/ntservice.h
parent7d9befe0e06a373a3212496993fa54f52948b4f1 (diff)
downloadmongo-c9c9dc5b03d78af082e8ba7da282261470e028bd.tar.gz
Added support for running mongod as a Windows NT Service
Signed-off-by: mongodb <mongodb@10gen.com>
Diffstat (limited to 'util/ntservice.h')
-rw-r--r--util/ntservice.h48
1 files changed, 48 insertions, 0 deletions
diff --git a/util/ntservice.h b/util/ntservice.h
new file mode 100644
index 00000000000..b9670aa69f7
--- /dev/null
+++ b/util/ntservice.h
@@ -0,0 +1,48 @@
+// ntservice.h
+
+/**
+* Copyright (C) 2008 10gen Inc.
+*
+* This program is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Affero General Public License, version 3,
+* as published by the Free Software Foundation.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Affero General Public License for more details.
+*
+* You should have received a copy of the GNU Affero General Public License
+* along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#pragma once
+
+#if defined(_WIN32)
+
+namespace mongo {
+
+ typedef bool ( *ServiceCallback )( void );
+
+ class ServiceController {
+ public:
+ ServiceController();
+ virtual ~ServiceController() {}
+
+ static bool installService( const std::wstring& serviceName, const std::wstring& displayName, const std::wstring& serviceDesc, 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 );
+
+ static void WINAPI initService( DWORD argc, LPTSTR *argv );
+ static void WINAPI serviceCtrl( DWORD ctrlCode );
+
+ protected:
+ static std::wstring _serviceName;
+ static SERVICE_STATUS_HANDLE _statusHandle;
+ static ServiceCallback _serviceCallback;
+ };
+
+} // namespace mongo
+
+#endif