View previous topic :: View next topic |
Author |
Message |
ShaDoOoW
Joined: 20 Aug 2005 Posts: 584
|
Posted: Tue Jul 20, 2010 17:38 Post subject: MySQL starting time |
|
|
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 |
|
|
Paul R
Joined: 17 Apr 2009 Posts: 42
|
Posted: Tue Jul 20, 2010 20:18 Post subject: |
|
|
(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 |
|
|
Baaleos
Joined: 02 Sep 2007 Posts: 830
|
Posted: Wed Jul 21, 2010 3:25 Post subject: |
|
|
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 |
|
|
ShaDoOoW
Joined: 20 Aug 2005 Posts: 584
|
Posted: Fri Jul 23, 2010 21:27 Post subject: |
|
|
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 |
|
|
Baaleos
Joined: 02 Sep 2007 Posts: 830
|
Posted: Fri Jul 23, 2010 22:52 Post subject: to do that |
|
|
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 |
|
|
Gryphyn
Joined: 20 Jan 2005 Posts: 431
|
Posted: Sat Jul 24, 2010 2:54 Post subject: |
|
|
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 |
|
|
Baaleos
Joined: 02 Sep 2007 Posts: 830
|
Posted: Sat Jul 24, 2010 3:52 Post subject: Chicken and the Egg |
|
|
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 |
|
|
Asparius
Joined: 18 Sep 2007 Posts: 52
|
Posted: Sat Jul 24, 2010 13:52 Post subject: |
|
|
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 |
|
|
Baaleos
Joined: 02 Sep 2007 Posts: 830
|
Posted: Sat Jul 24, 2010 15:25 Post subject: |
|
|
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 |
|
|
ShaDoOoW
Joined: 20 Aug 2005 Posts: 584
|
Posted: Tue Aug 31, 2010 14:55 Post subject: |
|
|
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 |
|
|
Gryphyn
Joined: 20 Jan 2005 Posts: 431
|
Posted: Wed Sep 01, 2010 2:28 Post subject: |
|
|
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 |
|
|
|