logo logo

 Back to main page

The NWNX Community Forum

 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Clean restart solution

 
Post new topic   Reply to topic    nwnx.org Forum Index -> General Discussion
View previous topic :: View next topic  
Author Message
A



Joined: 19 Jun 2008
Posts: 8

PostPosted: Thu Jun 19, 2008 20:48    Post subject: Clean restart solution Reply with quote

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):

Arrow NWServer can be shut down from command line. Process can be closed, killed or even crashed. Command is sent via LETO.

Arrow Certain NWScript constructions may cause imidiate crash.

Arrow Plugin I found here cause NWServer crash. This is pretty much same as previous solution.

Arrow 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
View user's profile Send private message
A



Joined: 19 Jun 2008
Posts: 8

PostPosted: Thu Jun 19, 2008 21:00    Post subject: Reply with quote

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 Very Happy
Back to top
View user's profile Send private message
Disco



Joined: 06 Dec 2006
Posts: 152

PostPosted: Fri Jun 20, 2008 15:36    Post subject: Reply with quote

Isn't there some command called KILLSERVER that you can send to NWNX from NWN?
Back to top
View user's profile Send private message
virusman



Joined: 30 Jan 2005
Posts: 1020
Location: Russia

PostPosted: Fri Jun 20, 2008 17:49    Post subject: Reply with quote

http://data.virusman.ru/nwn/nwnx_resetplugin-0.3rc-win32.rar
Please tell me whether this fixes the issue or not.
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger
A



Joined: 19 Jun 2008
Posts: 8

PostPosted: Fri Jun 20, 2008 19:47    Post subject: Reply with quote

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
View user's profile Send private message
Disco



Joined: 06 Dec 2006
Posts: 152

PostPosted: Fri Jun 20, 2008 23:59    Post subject: Reply with quote

Ahhh. OK.

Save and boot players in a delayed loop. In the meantime you block anyone entering with BootPlayer in OnClientEnter.
Back to top
View user's profile Send private message
ShaDoOoW



Joined: 20 Aug 2005
Posts: 584

PostPosted: Sun Jun 22, 2008 6:45    Post subject: Reply with quote

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
View user's profile Send private message
Skywing



Joined: 03 Jan 2008
Posts: 321

PostPosted: Sun Jun 22, 2008 7:23    Post subject: Reply with quote

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
View user's profile Send private message
A



Joined: 19 Jun 2008
Posts: 8

PostPosted: Sun Jun 22, 2008 15:32    Post subject: Reply with quote

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
View user's profile Send private message
Skywing



Joined: 03 Jan 2008
Posts: 321

PostPosted: Sun Jun 22, 2008 18:34    Post subject: Reply with quote

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
View user's profile Send private message
A



Joined: 19 Jun 2008
Posts: 8

PostPosted: Mon Jun 23, 2008 4:37    Post subject: Reply with quote

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:

Arrow 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 Very Happy

A
Back to top
View user's profile Send private message
Skywing



Joined: 03 Jan 2008
Posts: 321

PostPosted: Mon Jun 23, 2008 5:42    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    nwnx.org Forum Index -> General Discussion All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group