nb Core Community
February 09, 2012, 06:49:39 pm *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: 1.2.3 +nb is now final and released

@new registrations. I will not allow any new registrations here as there are more (real person) spambots here than ever.... captcha proved to be ineffective.

After your registration, mail me at ( admin AT shinobilegends.com ) from the mail address you want to register. Provide some text about you and possibly your game.
 
   Home   Help Search Calendar Downloads Login Register  
Pages: [1] 2
  Print  
Author Topic: Cron Job for Newday Runonce  (Read 3304 times)
Alchemion
Guest
« on: September 26, 2008, 01:04:57 am »

There is an issue that would be great solved here: the newday runonce cron job....

There is a post on DP made by you there, but seems not to be any more applicable to the nb+ core engine croned newday ...

So, there is a
Code:
$game_dir='';
in the settings.php which is commented out with
Code:
//enter here the directory of your datacache, this cannot be done elsewhere
... this gamedir reffers to the directory within the game directory, where it stored all the game cache ?... i.e. my cache directory is called "cache"... do i mention this one ? or ?...

my nb-core engine game is installed directly into the domain root i.e. at www.nb-engine.net ... in that case, $game_dir='' should be left unfilled ?...

if all is set throug settings.php, is it necessary to edit also the cron.php file ?...
 here there is :
 
Code:
if ($game_dir!='') {
require("lib/newday/newday_runonce.php");
 

so, the explanations from DP don't apply here ?!...

thanks.


Logged
Nightborn
Administrator
Sr. Member
*****

Karma: +20/-0
Posts: 306



View Profile WWW
« Reply #1 on: September 26, 2008, 07:40:41 am »

Thanks, wrong explanation (never copy dbconnect.php and forget to edit all ^^)

This should be more clear

  5 $game_dir='';
  6 // enter the directory of your game installation, this cannot be done elsewhere
  7 // for example
  8 // $game_dir='/var/www/html/lotgd';
  9 // This DEPENDS on your hosting! It is 100% sure if you use shared hosting this is different
 10 // If you have a rootserver, you'd know what your directory is =)



Oh, and if you have <1000 users registered, you don't need the cronjob setup.
Logged

It should be fixed, but it won't be easy and it won't be fast. If you want
to help - wonderful. But keep in mind that it will take months of wading
through the ugliest code we have in the tree. If you've got a weak stomach -
stay out. I've been there and it's not a nice place.

   - Al Viro
Alchemion
Guest
« Reply #2 on: September 26, 2008, 10:58:08 am »

that should be clear enogh...

so the gamedir would be set only in settings.php...

the rest remains the admins job to test the cron etc.

thanks.
Logged
Nightborn
Administrator
Sr. Member
*****

Karma: +20/-0
Posts: 306



View Profile WWW
« Reply #3 on: September 26, 2008, 02:37:20 pm »

You only need to set the $gamedir so the cronjob knows where it is executed.

It has no chance of knowing where its files really are else.

When you run it via the game itself, the Apache sets the BASEDIR for any require() stuff.

Sadly, when you do it via cronjob, you call the file cron.php directly - and it cannot require any other files if you don't say him what his base directory is.

If you want to test it, go to your console (SSH) and execute something like
Code:
php /var/www/html/lotgd/cron.php
(note to insert your right directory) and don't change your working directory to your gamedirectory! Else you won't see if it works or not.
You need the package php-cli if you have a debian distribution, else the appropriate one for your installation.

It should spit out some errors if it does not work, else you won't get anything back - it just runs the newday.
« Last Edit: September 26, 2008, 02:39:33 pm by Nightborn » Logged

It should be fixed, but it won't be easy and it won't be fast. If you want
to help - wonderful. But keep in mind that it will take months of wading
through the ugliest code we have in the tree. If you've got a weak stomach -
stay out. I've been there and it's not a nice place.

   - Al Viro
Alchemion
Guest
« Reply #4 on: October 20, 2008, 09:02:39 am »

I could not get the root to my game engine, so i have inserted a dummy gamedir...

Waiting for an error message to be sent by mail, as it should, nothing came by mail...

I have seen that, in case of mispeled gamedir address, the real address would have been pointed out by admin mail message....

Yet, it seems the cron job messaging is not doing its supposed mailing alert ...

Please, review this.

Thank you.
Logged
Nightborn
Administrator
Sr. Member
*****

Karma: +20/-0
Posts: 306



View Profile WWW
« Reply #5 on: October 20, 2008, 11:41:53 am »

Quote
Yet, it seems the cron job messaging is not doing its supposed mailing alert ..

Erm, who said there is a check if it runs or not and then alerts?

A cron job (to my knowledge) only sends an email if anything happened on the STDERR channel.
However lotgd fetches most stderr output... and sends out STDOUT text about it.

if you did an incorrect setup, it will just not work.

if it runs, check your gamelog in the grotto.

If you have no root server and you can't get the current dir of your installation, just let it run without cron.

It is REALLY just an extra for experienced admins with servers beyond 1000 users.
Logged

It should be fixed, but it won't be easy and it won't be fast. If you want
to help - wonderful. But keep in mind that it will take months of wading
through the ugliest code we have in the tree. If you've got a weak stomach -
stay out. I've been there and it's not a nice place.

   - Al Viro
Alchemion
Guest
« Reply #6 on: October 20, 2008, 04:04:42 pm »

Quote
Erm, who said there is a check if it runs or not and then alerts?

I read this inside cron.php and I assumed it was the answer...

Quote
mail($email,"Cronjob Setup Screwed",sprintf("Sorry, but the gamedir is not set for your cronjob setup at your game at %s.\n\nPlease correct the error or you will have *NO* server newdays.",getsetting('serverurl','')));

... so, maybe I got it wrong, cause my lack of programming knowledge...

Yet, if it is a check or it is not, please suggest what code and where would it be good to add or correct so that it indeed returns the information about the real gamedir... ??!!

Quote
It is REALLY just an extra for experienced admins with servers beyond 1000 users.

though i am not an extra experienced admin, my game has over 2000 players registered (at least the former engine had, until my hoster forced me to close it down... now I am working on a better public version and hope to a less buggy and more speedy one Smiley, though only a few simultaneous online and though the server needs cleaning up more accounts... i assume this cron would prove itself useful...
« Last Edit: October 20, 2008, 04:28:16 pm by Alchemion » Logged
Nightborn
Administrator
Sr. Member
*****

Karma: +20/-0
Posts: 306



View Profile WWW
« Reply #7 on: October 20, 2008, 08:07:40 pm »

Alright.

Quote
I read this inside cron.php and I assumed it was the answer...

Please read the code. This test does only check if the chdir() was successful or not. Not if the cronjob run.
It is a first failsafe if people do chdir to directories that won't work.
If the $gamedir is empty, it will go on, no mail.
If the gamedir is a wrong one, but you can change your working directory, it will work.

Read the last comment.
If you leave it empty, the cronjob will just not run.

Quote
though i am not an extra experienced admin, my game has over 2000 players registered (at least the former engine had, until my hoster forced me to close it down... now I am working on a better public version and hope to a less buggy and more speedy one Smiley, though only a few simultaneous online and though the server needs cleaning up more accounts... i assume this cron would prove itself useful...

Well, what I don't know I can't incorporate in my suggestions.
2000 - depends on how many online and what "few" is in your  terms... then how long the expiration time is.

Let's say cron is useful.

Then I can assume you run on a full root machine for that number of players, yes? webhosting? vhost?
Logged

It should be fixed, but it won't be easy and it won't be fast. If you want
to help - wonderful. But keep in mind that it will take months of wading
through the ugliest code we have in the tree. If you've got a weak stomach -
stay out. I've been there and it's not a nice place.

   - Al Viro
Alchemion
Guest
« Reply #8 on: October 21, 2008, 04:46:39 pm »

to tell you honestly, i managed to get a glimpse, at a moment back in time, of the root address... but i lost where i got to see that... i have to look thouroughly when i get myself some spare time these days...

nevertheless, it would be of great help to get that code working... from cron.php ... regarding the mailed message informing of the real server address....

would you intend to improve the cron.php with this option, also ?...

until you may do so with the next release, please, give us a hand with the actual code... you would also spare us a deal of lot of "searching for the address" time...

thank you very much for your help so far.
Logged
Nightborn
Administrator
Sr. Member
*****

Karma: +20/-0
Posts: 306



View Profile WWW
« Reply #9 on: October 21, 2008, 06:32:43 pm »

I can't improve it as I don't know when the cronjob REALLY runs.

You find in 1.2.1 an altered cron.php that checks both things, but as you did not get a mail from a failed chdir() it's pretty hopeless.

Erm, well, if you don't know your game directory... Oo

ever tried the rawsql -> php section in the grotto with
Code:
output(getcwd());

http://php.net <--good stuff =)
Logged

It should be fixed, but it won't be easy and it won't be fast. If you want
to help - wonderful. But keep in mind that it will take months of wading
through the ugliest code we have in the tree. If you've got a weak stomach -
stay out. I've been there and it's not a nice place.

   - Al Viro
Nightborn
Administrator
Sr. Member
*****

Karma: +20/-0
Posts: 306



View Profile WWW
« Reply #10 on: October 23, 2008, 08:13:29 am »

sorry, double post


small typo in cron.php -> gamedir instead of game_dir

please correct that or download again, else the  cron will never run.
Logged

It should be fixed, but it won't be easy and it won't be fast. If you want
to help - wonderful. But keep in mind that it will take months of wading
through the ugliest code we have in the tree. If you've got a weak stomach -
stay out. I've been there and it's not a nice place.

   - Al Viro
Alchemion
Guest
« Reply #11 on: October 24, 2008, 10:09:24 am »

Quote
output(getcwd());

this trick solved the issue.... thank you very much....

also, I remembered howelse one can see the server url... by setting on the Php Notice Output, from Site Nofications, from the Game settings...

Quote
small typo in cron.php -> gamedir instead of game_dir

I see just now, why I was waiting for a miracle to happen and it refused obstinately...  Tongue

Thanks for the correction, I will test it this evening...

Best regards!
Logged
Alchemion
Guest
« Reply #12 on: October 27, 2008, 02:38:55 pm »

Hi,

Got back with some good news...

The cron still does not work...  Cry   it appears I already had $game_dir both in settings.php as well in cron.php ... I don't bet that changing the $game_dir into $gamedir in both files would do the trick ?...

While typing it occured to me that I should try change the name in both files and see what happens... Smiley

Anyway, can you explain in little short terms of the newday cron here ?... what is supposed this cron to do ?... how does it manifest ?... how do I know this cron worked and did what it was supposed to ?.....

Thank you very much.
Logged
Nightborn
Administrator
Sr. Member
*****

Karma: +20/-0
Posts: 306



View Profile WWW
« Reply #13 on: October 27, 2008, 03:55:51 pm »

Hi,

it's generally a really bad idea to activate a feature when you have no knowledge what it does.

http://en.wikipedia.org/wiki/Cron

erm, yes the $game_dir must be the same in settings.php AND cron.php ... if the variable name is spelled differently -> change them to the same name.

Server Stuff:
if you want to know more, go to the console, and do "man cron" ...
if you want to run the cronjob on console level manually: "php cron.php" and see if an error pops up. As said, I do NOT check if it runs or not in the script.

You will know it worked when your game log refreshes Wink as I already told you.
(Char expiration etc)
Logged

It should be fixed, but it won't be easy and it won't be fast. If you want
to help - wonderful. But keep in mind that it will take months of wading
through the ugliest code we have in the tree. If you've got a weak stomach -
stay out. I've been there and it's not a nice place.

   - Al Viro
Alchemion
Guest
« Reply #14 on: October 27, 2008, 04:31:54 pm »

Unfotunately and basicly, I know what a cron is...

As for the game log, it appears nothing happens... every new day I enter the game area, the newday runonce issues... isn't the cron supposed to run the newdayrunonce once and for all and never occuring for the usual player ?...

I tested the cron.php in the webhosting cpanel and I got this :

Quote
Connecting:...........Connected
Testing: http://nb-core.engine.sample/cron.php

Result:
403 - Forbidden - Access is forbidden to the requested page


Testing done!

Get any idea about this error and where it occurs ?... (I have allowed from settings as well from cronjobs cpanel, the running of cron.php at a specific time)

Thanks.

Logged
Pages: [1] 2
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!