pdinklag / MinecraftStats

A Minecraft player statistics browser for the web - supports 1.13 and later!
https://discord.gg/brH5PGG8By
Other
228 stars 54 forks source link

Auto update. #72

Closed TehloWasTaken closed 5 years ago

TehloWasTaken commented 5 years ago

So as you know in the last Issue I had everything fixed, and it seemed like it was auto updating but it wasn't. Is there any way to make it update automatically and how would I go about doing this?

I tried making a cronjob with to test it every 2 minutes but it didn't work Syntax: */2 * * * * python3 /var/www/html/stats/update.py -s /home/minecraft/multicraft/servers/server1 --server-name "§b§1Hydro§9 Vanilla SMP"

Thanks in advance!

pdinklag commented 5 years ago

Yes, cronjobs are the preferred way of handling this. Is there a data directory in your /home/minecraft/? I believe that your cronjob is executed with the home directory as working directory. However, you want /var/www/html/stats to be the working directory so data is created (and updated) there.

Try to switch to it first, like so:

*/2 * * * * cd /var/www/html/stats && python3 update.py -s /home/minecraft/multicraft/servers/server1 --server-name "§b§1Hydro§9 Vanilla SMP"
TehloWasTaken commented 5 years ago

Used what you told me to use, still isn't working. The data is under /var/www/html/stats/ and the other path is to my Minecraft Server Directory.

Isn't it easier to make a bash script and make the cronjob only execute the bash script while the bash script has the code for Python in it?

If so, how would I go about doing that.

As you can see here https://stats.hydrovanillasmp.com/ the last time it updated was yesterday night when I ran it manually.

TehloWasTaken commented 5 years ago

Just updated it again manually*

pdinklag commented 5 years ago

Used what you told me to use, still isn't working. The data is under /var/www/html/stats/ and the other path is to my Minecraft Server Directory.

Yes, because of your manual updates there certainly is a data directory in your stats path. But has it (e.g. the player.json) been updated?

Did the cronjob produce any errors? You can usually check by using the mail program as the cron user, or delegate all output to some kind of log file. That's indeed easier by using a script.

Isn't it easier to make a bash script and make the cronjob only execute the bash script while the bash script has the code for Python in it?

If so, how would I go about doing that.

Exactly like you said, put the line in a bash script and make the cronjob use that. I don't think this will fix the issue here though, it will just move the problem into the bash script.

pdinklag commented 5 years ago

Just so you know, it does seem to auto-update now. Unless you manually did it about every 10 minutes in the last half hour...?

pdinklag commented 5 years ago

Closing since it's apparently fixed.