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 
 
MySQL starting time

 
Post new topic   Reply to topic    nwnx.org Forum Index -> Database related
View previous topic :: View next topic  
Author Message
ShaDoOoW



Joined: 20 Aug 2005
Posts: 584

PostPosted: Tue Jul 20, 2010 17:38    Post subject: MySQL starting time Reply with quote

Got one issue that when my server have been turned on or restarted, nwnx runs before MySQL is really started. MySQL is installed as service though. Is there way to start NWNX after it will be possible to connect to MySQL? Other than check for db connection in nwscript and if its not bound, then do restart...
_________________
Community Patch / NWNX Patch / NWNX Files / NWNX Connect
Back to top
View user's profile Send private message
Paul R



Joined: 17 Apr 2009
Posts: 42

PostPosted: Tue Jul 20, 2010 20:18    Post subject: Reply with quote

(caveat I don't run the Windows version so this may not be relevant)

Guess it depends how you start nwnx, if it's as a service like srvany then try it as a delayed start service. If via startup folder or in the registry try using a cmd script and doing a net start command for MySQL and then nwnx after.

Paul
_________________
oops
Back to top
View user's profile Send private message
Baaleos



Joined: 02 Sep 2007
Posts: 830

PostPosted: Wed Jul 21, 2010 3:25    Post subject: Reply with quote

I had this problem too,
where nwnx tries to run before all the services are up n running.

I resolved it via a batch file.

In the bat file, tell it to
ping -n 10 127.0.0.1 >NUL

you can change the number 10, to whatever you want, to change the duration of the wait.

This basically tells it to ping itself for 10 seconds, which in my case at least, is enough time for php and mysql to get up and running.


so if your php/mysql service is started by running an executable, you can do this in a bat file

start C:\Servers\MYSQL\MYSQL.exe
ping -n 20 127.0.0.1 >NUL
start C:\Servers\NWN\NWNX2.exe


Note - In some cases, you will have problems with the arguments that nwnx tries to read in, eg - INI Values, or locating the modules folder, if you try to execute it from a folder location other than the nwn folder, or a folder shared with nwnx2.exe itself.

I resolved this by putting the BAT in the nwn folder, with nwnx2.exe, and then just execute a shortcut to the bat file instead, from the startup folder.
Back to top
View user's profile Send private message
ShaDoOoW



Joined: 20 Aug 2005
Posts: 584

PostPosted: Fri Jul 23, 2010 21:27    Post subject: Reply with quote

Guess I will try to change NWNX to not load module if it won't be able to connect db then. Not sure when I try that though.
_________________
Community Patch / NWNX Patch / NWNX Files / NWNX Connect
Back to top
View user's profile Send private message
Baaleos



Joined: 02 Sep 2007
Posts: 830

PostPosted: Fri Jul 23, 2010 22:52    Post subject: to do that Reply with quote

To do that, you will need to build a unique version of nwnx_odbc

The functions currently inside the database plugin, are designed to be accessed from nwn, but since your plan is to not load nwn server if the database connection cannot be established, it causes a chicken and egg sorta situation.

All in all, you would likely need
1. The nwnx2.exe to send a request to the odbc plugin, before module loading, and
2. The odbc plugin to respond to it.


My suggestion would be a 'while' loop, to determine if the database has become available.

Code:
eg - while(response == null)
          {
                 wait.....
            response = getnewresponse...
          }


But saying that, my method, of using the batch file to wait, seems to be sufficient.

Note, I think, its possible if you have mySQL installed on the machine, to make a windows bat file, which loops, while trying to connect to the mysql database.

It is possible to do mysql via command line, its called the mysql command line tool, it integrates into the windows cmd prompt.

Im not that skilled with cmd scripts, but I know they allow you to do loop, and variables etc.

Which means you should be able to make it keep looping, until the database is up and running, then allow it to proceed to start nwnx.
Back to top
View user's profile Send private message
Gryphyn



Joined: 20 Jan 2005
Posts: 431

PostPosted: Sat Jul 24, 2010 2:54    Post subject: Reply with quote

In windows your can give services dependencies.
I'm sure there would be a similar facility in non-windows O/S's
Just make the NWNX service dependent on the MySQL one. This way NWNX will not start until/unless MySQL is already running.
Back to top
View user's profile Send private message
Baaleos



Joined: 02 Sep 2007
Posts: 830

PostPosted: Sat Jul 24, 2010 3:52    Post subject: Chicken and the Egg Reply with quote

In other news... I actually do know the answer to
"What came first, the chicken or the egg?"


The Chicken would have been born, from an egg, that was not a chicken egg. (Evolution - if your a believer)

So, you can say, 1. The Egg did come first, but 2. It wasnt technically a chicken egg, since it was laid by a bird of a different species.

Its like an indian woman giving birth to an 8 legged child..... The mutations can be that extreme even for animals, and these often give rise to new species.
One minute, you have a dodo, next minute, its laying an egg, which hatches in to a chicken.


Anyway... this was completely random, wanted to post it in the post above, but forgot.
Back to top
View user's profile Send private message
Asparius



Joined: 18 Sep 2007
Posts: 52

PostPosted: Sat Jul 24, 2010 13:52    Post subject: Reply with quote

Hmmm... a crude solution would be somethong like this:
Make a program that repeatedly attempts to connect to mysql database.
When this program succesfully connects and run a query (like "SELECT NOW()"), it will run nwnx2.exe.

Still it leaves a problem when mysql crash during server running...
Back to top
View user's profile Send private message
Baaleos



Joined: 02 Sep 2007
Posts: 830

PostPosted: Sat Jul 24, 2010 15:25    Post subject: Reply with quote

A batch file csn do all of this no need for a program. I used a bat file for my garrys mid server, it would automatically restart the server if the process ever vanished.
Back to top
View user's profile Send private message
ShaDoOoW



Joined: 20 Aug 2005
Posts: 584

PostPosted: Tue Aug 31, 2010 14:55    Post subject: Reply with quote

Gryphyn wrote:
In windows your can give services dependencies.
I'm sure there would be a similar facility in non-windows O/S's
Just make the NWNX service dependent on the MySQL one. This way NWNX will not start until/unless MySQL is already running.
can someone provide me command to make NWNX service dependant on MySQL? I somehow can't make it work, thanks.
_________________
Community Patch / NWNX Patch / NWNX Files / NWNX Connect
Back to top
View user's profile Send private message
Gryphyn



Joined: 20 Jan 2005
Posts: 431

PostPosted: Wed Sep 01, 2010 2:28    Post subject: Reply with quote

ShaDoOoW wrote:
Gryphyn wrote:
In windows your can give services dependencies.
I'm sure there would be a similar facility in non-windows O/S's
Just make the NWNX service dependent on the MySQL one. This way NWNX will not start until/unless MySQL is already running.
can someone provide me command to make NWNX service dependant on MySQL? I somehow can't make it work, thanks.


Add a registry entry http://support.microsoft.com/kb/193888
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    nwnx.org Forum Index -> Database related 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