[Windows] Bukkit-Watch an Auto-Reboot Batch File (With Logging)

Discussion in 'Bukkit Discussion' started by FlyingMongoose, Jun 15, 2011.

Thread Status:
Not open for further replies.
  1. Offline

    FlyingMongoose

    I didn't know where to put this because I don't know how applicable it is and/or where.

    So I've been working with, fiddling with, setting up, and, of course, playing on and/or with game servers for more than half my life now (No, really, I'm 25 and I started when I was 12). A large portion of that revolved around Valve games, and through that I came across a useful auto-reboot batch from srcds.com (their 'advanced' recommendation on the Windows Server page)

    So, I decided to modify it, heavily, for use with bukkit, and I hope/think it will please people.

    Features
    • Batch file can be placed ANYWHERE
    • Logging
      • Allows user to set a log folder
        • Creates the log folder if it is not present
      • Creates fresh log file per-day so long as a logged action occurs
      • Each item logged is time stamped
    • Starts bukkit
    • Restarts bukkit if one of the following occurs
      • Crash (so long as there is no prompt window)
      • "stop" command
    It will NOT restart if the "X" on the java console window is closed, it will, however, confirm that you want to terminate the batch. Closing your server in this method is NOT recommended (it doesn't always save).

    To use this you WILL NEED TO MANUALLY EDIT THE FILE!

    Installation
    1. Download 'bukkit-watch.bat.txt'
    2. Save anywhere
    3. Edit in your favorite text editor according to the Configuration section
    4. Save
    5. Rename to 'bukkit-watch.bat' - excluding quotes
    6. Run
    Configuration
    • Variables
      • servername
        • Line 28
        • Set whatever you want
        • Sets the following
          • Log Names
          • Window title for Java/Bukkit
          • Window Title for Batch cmd prompt
      • path
        • Line 34
        • Set to the full path of your bukkit directory
          • Include drive letter, and no trailing slashes
        • Sets the following
          • Full path and/or working directory
          • The log folder is creates in this
      • cbfile
        • Line 40
        • Set to the FULL name of craftbukkit.jar
          • Current: craftbukkit-0.0.1-SNAPSHOT.jar
        • Sets the following
          • The file to be executed by Java
      • logs
        • Line 46
        • Set to any folder-name you want (so long as characters are supported by your system)
        • Sets the following
          • Directory to be created inside of path if not already there
          • Directory for logs to be saved to
      • java7
        • Line 54
        • Default
          • false
        • If you wish to utilize Java 7, set to true
      • x86on64
        • Line 62
        • Default
          • false
        • If you are on a 64 bit machine, but want to run, or are only running the x86 (32bit) version of java, set this to true
    So, without further adieu, my totally awesome batch file for Windows (java 6 or 7, and 64 bit or 32 bit, so long as you change the proper variable.)

    And linux users don't think I forgot about you, once I get my *nix machine re-installed I'll work on a pretty little bash file for use as a daemon too (with similar operation). Honestly Mac OSX users are kinda on their own since I don't own one, but if you're fluent enough you will be able to modify from the bash I make for linux in the future.
     

    Attached Files:

    rakiru likes this.
  2. Offline

    MetalMadness

    I like it, I just want staff to take a look at it before I use it
     
  3. Offline

    FlyingMongoose

    That's fine, it's just basic lightweight batch script really, the only logging it really does is tell you when the server starts, when it crashes, and when it restarts, but that's all this script does anyway, so it doesn't need to log anything else. I've used it to control a number of server types in the past. I'm working on a linux daemon of similar properties. If you do use it let me know if you have any problems.

    Oh and could a mod please move this to the tools forum please. Thank you, I didn't see it when I posted.. *facepalm*
     
  4. Offline

    panade

    hmm i also was thinking about a batch script, but as u said it doesnt detect any java error freeze spam right?
    because this is the main issue on my server. :-(
    i never saw the batch promt of craftbukkit crashing.

    or did i misunderstand u with this java part?
     
  5. Offline

    FlyingMongoose

    I honestly don't know for sure, all I know for sure is when I x'd my command prompt of bukkit or ran stop within it, the batch automatically rebooted it. Which implies a "straight crash", I'm assuming any error output crashes or freezes may still need to be handled manually, but there's only one way to find out... test.

    I do know that batch scripts are extremely simple, and all this really does is see if the process still exists while going through an infinite loop. If it is it doesn't execute a thing, if it's not it launches a fresh process. So a freeze would imply the server (the java command prompt) is still running, so I don't necessarily see this handling freezes. I could probably sit down and write a proper daemon in a proper coding language that would check to see if the process RESPONDS, but it will take a while.
     
  6. Offline

    RazorFlint

    Very Very Nice. Speechless...
     
  7. Offline

    panade

    err what? are u kidding me?
    i never said im scared about XD
    meaybe u missreaded the name....

    my question is if its possible to detect java errors or crashes... because in my old classic server the software just shut down... but in java its all runing over the vm so im unsure if its possible to detect it at all.
    and at least i am better at bash as in batch XD because unix offer way more stuff :-P
     
  8. Offline

    FlyingMongoose

    Yes unix bash is quite nice but touchy as hell.
     
  9. Offline

    DoJo_Master

    sorry I cant seem to find the download link can you reply it to me?
     
  10. Same problem. Where can I download it?
     
Thread Status:
Not open for further replies.

Share This Page