View previous topic :: View next topic |
Author |
Message |
A
Joined: 19 Jun 2008 Posts: 8
|
Posted: Thu Jun 19, 2008 20:48 Post subject: Clean restart solution |
|
|
Hello everyone,
I am looking for NWNX plugin that provide function to regular end of NWServer. Something like DMREBOOT from NWN-FF.
Solutions I tried (and don't like):
NWServer can be shut down from command line. Process can be closed, killed or even crashed. Command is sent via LETO.
Certain NWScript constructions may cause imidiate crash.
Plugin I found here cause NWServer crash. This is pretty much same as previous solution.
Use NWN-FF.
I know how to make restarts safe. Refuse new logins, boot all players etc.. I just dislike time out message players recieve. I think NWN-FF solution is way better.
Is there such plugin? |
|
Back to top |
|
|
A
Joined: 19 Jun 2008 Posts: 8
|
Posted: Thu Jun 19, 2008 21:00 Post subject: |
|
|
I never seen C++ before but I guess it can't be so hard. I mean, NWN-FF is open source, it should be possible implement similiar function to NWNX.
Or maybe not. Excuse me |
|
Back to top |
|
|
Disco
Joined: 06 Dec 2006 Posts: 152
|
Posted: Fri Jun 20, 2008 15:36 Post subject: |
|
|
Isn't there some command called KILLSERVER that you can send to NWNX from NWN? |
|
Back to top |
|
|
virusman
Joined: 30 Jan 2005 Posts: 1020 Location: Russia
|
|
Back to top |
|
|
A
Joined: 19 Jun 2008 Posts: 8
|
Posted: Fri Jun 20, 2008 19:47 Post subject: |
|
|
virusman wrote: | http://data.virusman.ru/nwn/nwnx_resetplugin-0.3rc-win32.rar
Please tell me whether this fixes the issue or not. |
Is this modified plugin from Asmodae?
Code: | SetLocalString(GetModule(), "NWNX!RESETPLUGIN!SHUTDOWN", "1") |
For me it doesn't work. It only crash crash server much faster then before. Characters are not saved and player time out. |
|
Back to top |
|
|
Disco
Joined: 06 Dec 2006 Posts: 152
|
Posted: Fri Jun 20, 2008 23:59 Post subject: |
|
|
Ahhh. OK.
Save and boot players in a delayed loop. In the meantime you block anyone entering with BootPlayer in OnClientEnter. |
|
Back to top |
|
|
ShaDoOoW
Joined: 20 Aug 2005 Posts: 584
|
Posted: Sun Jun 22, 2008 6:45 Post subject: |
|
|
Quote: | Certain NWScript constructions may cause imidiate crash. |
I'm very curious to this, can you post such script? _________________ Community Patch / NWNX Patch / NWNX Files / NWNX Connect |
|
Back to top |
|
|
Skywing
Joined: 03 Jan 2008 Posts: 321
|
Posted: Sun Jun 22, 2008 7:23 Post subject: |
|
|
The way I handled this for NWNX4 was to find the server GUI window and post a WM_CLOSE message to it. This cleanly logs players out, saves characters, and shuts down.
I believe that this will (probably) work for nwserver.exe as well as nwn2server.exe in principle. For the linux nwserver, I assume that you'll have to do something a bit more complicated. |
|
Back to top |
|
|
A
Joined: 19 Jun 2008 Posts: 8
|
Posted: Sun Jun 22, 2008 15:32 Post subject: |
|
|
I just made it. I'll post final dll when I put it all together.
I found alot useful guides on MSDN.
How my rebooter work:
NWNX recieve reboot command.
Plugin enumerate running processes and find PID of nwserver.exe.
ID is sent to function that attempt terminate process by WM_CLOSE.
Function return SUCCESS/FAILURE.
NWServer is regulary closed, characters saved and NWNX restart it.
// I can add KillProcess if regular close failed, not sure yet. Or sent failure message to module. |
|
Back to top |
|
|
Skywing
Joined: 03 Jan 2008 Posts: 321
|
Posted: Sun Jun 22, 2008 18:34 Post subject: |
|
|
You could also look at the following functions in the NWNX4 controller:
NWNXController::findServerGuiWindowEnumProc
NWNXController::findServerGuiWindow
NWNXController::performGracefulShutdown
It seems likely to me that the window class is probably the same for nwserver as for nwn2server.
http://nwn.virusman.ru/svn/nwnx4/trunk/src/controller/controller.cpp |
|
Back to top |
|
|
A
Joined: 19 Jun 2008 Posts: 8
|
Posted: Mon Jun 23, 2008 4:37 Post subject: |
|
|
I created small plugin with functions I needed for my server.
It is my first try in C++ so i guess code is not very good, but it do what I wanted.
Implemented funcions:
Code: | SetLocalString(GetModule(), "NWNX!SHELL!SHUTDOWN", "CLOSE"); |
This cause regular end of NWServer, characters are saved and application closed.
Code: | SetLocalString(GetModule(), "NWNX!SHELL!SHUTDOWN", "KILL"); |
NWServer process is terminated imidiately. This not giving NWServer chance process ending sequence and players recieve timeout message. This is well known "crash" function.
Code: | SetLocalString(GetModule(), "NWNX!SHELL!CMD", "command string"); |
This pass command string to operating system. Usually cmd.exe but can be anything defined in %COMSPEC% variable.
Known Issues:
My plugin not working with more then one instances of nwserver.exe. Copy with lower process ID (PID) will be affected.
If somebody find my plugin useful, here is download:
http://www.aurilites.com/NWNX/nwnx_shell.zip
I will be adding more functions later, everything related to operating system. If you find bug or have idea how improve my plugin, let me know
A |
|
Back to top |
|
|
Skywing
Joined: 03 Jan 2008 Posts: 321
|
Posted: Mon Jun 23, 2008 5:42 Post subject: |
|
|
You should filter the window you search for by the current process ID to solve the problem of not working with multiple instances.
(see GetWindowThreadProcessId, GetCurrentProcessId) |
|
Back to top |
|
|
|