Jump to content

[Patch][7271] Mangosd shutdown as Windows Service

Auntie Mangos

Recommended Posts

  • * What bug does the patch fix?
Allows mangosd to be shutdown by the Service Control Manager when running as a Service in Windows.

  • * For which repository revision was the patch created?

  • * Is there a thread in the bug report section or at lighthouse? If yes, please add a link to the thread.

  • * Who has been writing this patch? Please include either forum user names or email addresses.

This feature has been broken for a couple thousand revs, so I'd be really happy to see it work again.

diff --git a/src/mangosd/WorldRunnable.cpp b/src/mangosd/WorldRunnable.cpp
index 2e97f97..a4c133d 100644
--- a/src/mangosd/WorldRunnable.cpp
+++ b/src/mangosd/WorldRunnable.cpp
@@ -36,6 +36,11 @@
#define WORLD_SLEEP_CONST 100                               //Is this still needed?? [On linux some time ago not working 50ms]
+#ifdef WIN32
+#include "ServiceWin32.h"
+extern int m_ServiceStatus;
/// Heartbeat for the World
void WorldRunnable::run()
@@ -70,6 +75,11 @@ void WorldRunnable::run()
            prevSleepTime = 0;
+            #ifdef WIN32
+        if (m_ServiceStatus == 0) World::StopNow(0);
+            while (m_ServiceStatus == 2) Sleep(1000);
+            #endif
    sWorld.KickAll();                                       // save and kick all players

Link to comment
Share on other sites

  • 39 years later...

Hmm, okay that doesn't work quite as I intended. When hitting stop from services.msc, the process begins to start again (?). In otherwords, if I check the log file, it re-uses the same log file.

2009-02-08 13:16:44 Max allowed socket connections 4096

2009-02-08 13:17:05 Halting process...

2009-02-08 13:17:05 MaNGOS/0.13.0-DEV (* * Revision 7252 - 0b3748bf5f75c34695f9ed1b9cfb929f1d2d3aef) for Win32 (little-endian) [world-daemon]

2009-02-08 13:17:05 <Ctrl-C> to stop.

...the service itself stops (and reflects that), and the process will stop a few seconds later (10 to 15 or so) and the log file will be cut off while loading a certain table. Kind of strange.

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use