DOH! Network

  • News
  • ...
  • Johnny Leche

Welcome to the DOH! Network — The Official Website of Johnny Leche.

In setting up the new backup server I somehow went into my public_html folder on the old server and accidentally deleted the Gamedig module for Node that powers the DOH! Network Game Server Stats page and had never backed up that folder. I thought I could recreate the javascript pretty quickly but it turns out it wasn't a quick script. Luckily, I had a version stashed in another location I was going to use as the final destination but my crontab entry for starting it on server startup was still pointing to the location I deleted. Switched the location to the oher location and all is right with the world again. So what is required for setting up a page to return Gamedig stats? First, install Node and npm. There are a bunch of how-tos like this SlackBuilds Nodejs install one on those so I'm not talking about that part. Once those are installed, install Gamedig...

npm install gamedig

Next you'll need to set up a node server to broadcast the results of the gamedig call requiring `http`. I made it so I can pass parameters to gamedig from the url so I required `url` as well. The full code looks like this...

var http = require('http'),     url = require('url'),     gamedig = require('gamedig'),     headers = {},     queryObj;

http.createServer( function (req, res) { // add needed headers headers['Access-Control-Allow-Origin'] = '*'; headers['Access-Control-Allow-Methods'] = 'GET'; headers['Access-Control-Allow-Credentials'] = true; headers['Access-Control-Max-Age'] = '86400'; // 24 hours headers['Access-Control-Allow-Headers'] = 'X-Requested-With, Access-Control-Allow-Origin, X-HTTP-Method-Override, Content-Type, Authorization, Accept'; res.writeHead(200, headers); queryObj = url.parse(req.url, true).query; nPort = queryObj.p || undefined; data = { host: queryObj.h, // 'dohnetwork.com' type: queryObj.t // 'tf2' } };

if (nPort) { data.port = parseInt(nPort, 10); };

gamedig.query (data, function (state) { state.error ? res.end ('Server is offline') : res.end (JSON.stringify(state)); }).listen(3000, 'dohnetwork.com');

Then the games page calls the url like this... https://games.dohnetwork.com:3000/?h=dohnetwork.com&t=tf2 Add a Handlebars template to display all that JSON data nicely and you have a game server stats page. Now to fix the ecards cgi mailer.

The original DOH! Network server is online again until it decides to go own again while the backup server is being rebuilt. Looks like a bad power supply tha requires being unplugged for about 15 minutes before being turned on again. This will be the first time installing Slackware from an ftp site since the DVD I burned has bad files on it. The bad disc works at least enough to get the server to connect to the internet and start the download. Hopefully the original server doesn't go down in the middle of the install. The nice thing about downloading from the internet is I don't need to update everything to the latest version after install.

The DOH! Network is back online. The hosting facility has some janky electricity causing the server to go into a flashing orange power button light mode from time to time and this last instance took a longer than expected time to come back. Now would probably be a good time to get a backup server set up while I have a backup server sitting here.

Bethesda Softworks has released the new DOOM official multiplayer trailer. I was thinking I might need a new videocard playing GTA 5. Watching this trailer I know for sure I am going to. Check out the DOOM official multiplayer trailer now! Check out the DOOM official multiplayer trailer now!

dialog youtube