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.