[ADMIN] McMyAdmin v2 server configs: Upstart, Nginx

Discussion in 'Bukkit Tools' started by kreeger, May 2, 2012.

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

    kreeger

    Hey, folks — I've been lurking here for some time now, but it's time for me to make a post.

    I figured I would share some of the server setup stuff I've done with CraftBukkit and McMyAdmin v2 that may help some people. I do a lot of this kind of stuff at my day job (for real-deal websites and server processes), so it's kinda fun to come home and apply the same stuff to make my Minecraft setup better. So here's what's up.

    I've got a machine running Ubuntu Server 12.04 (brand-spankin'-new, least at the time of this post), and I used to be running just CraftBukkit with Essentials and EssentialsGroupManager. Last night, I decided to throw McMyAdmin v2 into the mix, which forced me to rework my Upstart init script I had (since McMyAdmin plays the role of the CraftBukkit/Minecraft server manager/watchdog). But I have it on a box with self-signed SSL (good enough for me, a hobbyist), along with Minecraft Overviewer, which is incredible in its own right, running side-by-side. In either case, I'll start with my Upstart init script, which fires up McMyAdmin. I'll note that all my Minecraft/McMyAdmin stuff sits in /usr/local/minecraft.
    Code:
    # /etc/init/minecraft.conf
     
    description "Minecraft server, wewt!"
     
    start on runlevel [2345]
    stop on runlevel [^2345]
     
    chdir /usr/local/minecraft
     
    exec su -s /bin/sh -c 'exec "$0" "[email protected]"' minecraft -- /usr/bin/mono McMyAdmin.exe -nostart /usr/local/minecraft/McMyAdmin.conf
    This way, I can run restart minecraft or status minecraft or stop minecraft… you get the idea. The only other thing that needs to happen once this script is in place is to link in the /lib/init/upstart-job script to /etc/init.d/minecraft, and you're all set for this part.

    The other bit I've got in place is a self-signed cert for McMyAdmin so I can login securely from wherever I'm at. I'm currently using Nginx for this, as it's possible in the future, I could have a couple of other things serving themselves up on this box, and I'd like to have a central location to manage them, especially if some of them require SSL. Nginx's great for serving up applications through proxies, so here's a real simple server config I'm running for McMyAdmin using the SSL cert and key I generated for myself (note that my McMyAdmin process is running on port 8888, which is what I've got it set to in my McMyAdmin.conf file).
    Code:
    # /etc/nginx/sites-available/mcma
     
    server {
     
      listen              443 ssl;
     
      ssl                on;
      ssl_certificate    /etc/ssl/certs/server.crt;
      ssl_certificate_key /etc/ssl/private/server.key;
      ssl_session_timeout 5m;
     
      server_name my.minecraft.server.com;
     
      location / {
        proxy_pass http://127.0.0.1:8888;
        proxy_set_header Host $host;
      }
    }
    Edit: PhonikUK, developer of McMyAdmin, has brought to my oblivious attention (see his post below) the fact that settings for using HTTPS/SSL exist within your McMyAdmin.conf file as well.

    Code:
    webserver.usehttps=true
    webserver.certificatepath=/etc/ssl/certs/server.crt
    webserver.port=443
    Now I've also got Minecraft Overviewer set up as a cron job that runs daily at about 4:15am and generates an updated map for the server to display in a slick Google Maps-esque format. If you operate your own server and you haven't looked at it yet, do yourself a favor and check it out. It's pretty slick. But here's my cron task for that.
    Code:
    05 4 * * * /usr/local/bin/overviewer.py --config=/usr/local/minecraft/config
    Overviewer's config file outputs it directly to the location where nginx serves it from (which is /usr/local/sites/minecraft/map, and here's that nginx config.
    Code:
    # /etc/nginx/sites-available/overviewer
     
    server {
     
      listen 80;
     
      root /usr/local/sites/minecraft;
      index index.html;
      server_name my.minecraft.server.com;
      location /map {
        try_files $uri $uri/ /index.html;
      }
    }
    I think that takes care of the bulk of the magic I've got on my server. As long as the nginx and minecraft services are running, my server runs like a champ. I'll also note that so far (in the 24 hours I've been running it), I'm extremely happy and impressed with McMyAdmin v2. I'll be running it for about the next 7 days or so, and if it treats me well, I'll be more than happy to plunk down the $16.20 USD (or so) for a Pro license. It's magnificent.

    Anyway, if you've got any questions about how my stuff is set up, post 'em! I'll do my best to respond to them. Thanks for reading!

    EDIT! I've setup a ramdisk on which my world resides now, using the common Linux ramdisk at /dev/shm. It's powered by two bash scripts, a cron job, and an upstart script. Here's the first bash script, that does the ramdisk creation on Minecraft server startup.
    Code:
    # /usr/local/minecraft/ramdisk-init.sh
    #!/bin/sh
    VOLATILE="/dev/shm/minecraft"
    PERMANENT="/usr/local/minecraft/storage/"
    rsync -r -t -v "$PERMANENT" "$VOLATILE"
    This is fired using Upstart, and it listens for whenever the minecraft job gets started (making this new job run first).
    Code:
    # /etc/init/minecraft-ramdisk.conf
    description "Minecraft ramdisk creation and management."
     
    start on starting minecraft
    stop on runlevel [^2345]
     
    task
     
    chdir /usr/local/minecraft
    exec su -s /bin/sh -c 'exec "$0" "[email protected]"' minecraft -- /bin/sh /usr/local/minecraft/ramdisk-init.sh
    Then I've got another script that does the sync back to my storage folder inside my Minecraft directory every 5 minutes (via cron).
    Code:
    # /usr/local/minecraft/ramdisk-backup.sh
    #!/bin/sh
    VOLATILE="/dev/shm/minecraft/"
    PERMANENT="/usr/local/minecraft/storage"
    rsync -r -t -v "$VOLATILE" "$PERMANENT"
    Here's the every-5-minute cron for that.
    Code:
    */5 * * * * sh /usr/local/minecraft/ramdisk-backup.sh
    Since I keep my world files safe and sound in /usr/local/minecraft/storage, as well as back them up with McMyAdmin, I'm good to go. This also means I've got the following symlinks in place.
    Code:
    /dev/shm/minecraft/world -> /usr/local/minecraft/world
    /dev/shm/minecraft/world_nether -> /usr/local/minecraft/world_nether
    /dev/shm/minecraft/world_the_end -> /usr/local/minecraft/world_the_end
     
    Pyrotech1620 likes this.
  2. Offline

    PhonicUK

    Yes it will. Three settings you need to change in McMyAdmin.conf :

    webserver.usehttps=true
    webserver.certificatepath=/path/to/certificate.pfx
    webserver.port=443 (or whatever else you want to use)

    Et voila, security happens!
     
  3. Offline

    kreeger

    Ah, man, I'm such a dope! I must have totally glossed over those first two settings. Thank you for those! I've edited my original post to include them.
     
  4. Offline

    Pyrotech1620


    Question for you or anyone.. I setup the /etc/init/minecraft.conf and it works fine when I am logged in and run sudo start minecraft or sudo stop minecraft .. I linked it to /etc/init.d/minecraft but it is not starting when ubuntu boots... Not sure whats going on but was going to see if you are having any problems with it starting on ubuntu boot? Anyhelp would be great.. =]
     
  5. Offline

    kreeger

    The stopping/starting lines weren't working for me, either. I ended up changing them to the following and putting them right below the "description" line.
    Code:
    description "Minecraft server, wewt!"
     
    start on runlevel [2345]
    stop on runlevel [^2345]
     
    chdir /usr/local/minecraft
     
    ...
    Those UNIX runlevel codes ought to work much better instead of the networking based lines. I'll amend my post.
     
  6. Offline

    Pyrotech1620


    Those lines worked great!! Thanks man!
     
    kreeger likes this.
  7. Offline

    kreeger

    Glad it works for you! I've set up a ramdisk for my server; I've amended my post above for that.
     
Thread Status:
Not open for further replies.

Share This Page