0

I've been searching for this for awhile now, and I am not sure if I am just not using the correct search terms or if the answer is really that hard to find.

What I am trying to do is to create a new Windows service for a game server from a batch file, and then have a task run another batch file every 30 minutes or more that would run two commands on the game server's command line and do some file work.

Specifically, I am running a Minecraft server using Bukkit for a gaming community I help run, and I want to make sure that the thing is always up unless I specifically tell it to stop (like a service). Bukkit is run directly from a batch file and has it's own command line thing running on it.

I am told that you CAN run this type of thing as a service, but the command line will be hidden from view and/or interaction. This is the second part of my query. I have a handy little backup.bat file that copies all the world files and userdata files into a backup directory, 7zips it, and deletes the directory. The only thing is, is that Minecraft likes to always have the worlds' region files open and writing at all times, meaning that it could cause map corruption if I just run it straight off. To compensate, I need to run the command "save-off" on the server to disable the file hooks temporarily, run the backup, and as soon as it finishes, run "save-on" so that the game can continue without lost data.

What I would like to know about this second one is, is it possible to interface with the game service through a batch file, or do I need to create an application to do that? If the latter, how exactly does one go about doing that? I have moderate C++ knowledge (up through my second OO-C++ course in college), and can possibly learn another language if absolutely necessary.

So, in short, two questions: 1. Is it possible to, and how to run a BAT file as a Windows Service? 2. How to interface with said service via BAT files, and if not possible, what kind of application do I need to write (redirection to or writing a tutorial works for me).

Thank you in advance for any and all help!

  • question 1) possible duplicate http://stackoverflow.com/questions/415409/run-batch-file-as-a-windows-service – PA. May 20 '11 at 12:32
  • Ah, thanks, seems I missed that one. So that's one part down. – Steeveeo May 20 '11 at 12:35
  • question 2) depends if the system to interface provides a *command line API* or not. – PA. May 20 '11 at 12:37
  • question 2b) If not, to write such command line app you need to google for a tutorial of using that particular Minecraft API. – PA. May 20 '11 at 12:38
  • @PA Not quite sure. I do see an API on their documentation page, but it appears to be for the actual server JAR instead of a command interface. Perhaps you could tell me otherwise (I'm a tad new to this kind of stuff)? http://wiki.bukkit.org/ – Steeveeo May 20 '11 at 12:43
  • @PA Google reveals nothing of use in that regard, sadly. Didn't help me before either. Frustratingly enough, it does show some articles and forums posts about people saying they HAVE done it, but they don't reveal their application or how they did it. – Steeveeo May 20 '11 at 13:57
  • Sorry I cannot help on that, neither. Never used this API before, in fact never used Minecraft even don't know what it is. – PA. May 20 '11 at 15:55

1 Answers1

0

Old question, user account doesn't seem active on SO anymore, but hey, if you stumble upon this because you have a similar problem:

Since we are speaking about a Bukkit Minecraft server, turn to the "Essentials" plugin for Bukkit. It now includes a Backup function that does exactly what the OP asks for, namely stop the save so the files can be manipulated without corruption, launch a script, then starts again.

The script can be a backup one (examples provided in the linked page) but can be used to run any operation on the world's files.

Silver Quettier
  • 2,045
  • 2
  • 26
  • 53