InstallationInstructions - JeffWaltzer/yet-another-space-war GitHub Wiki
These are the instructions for setting up a server to run Yet Another Space Wars (hereafter, YASW). I've tested these instructions on an Amazon AWS server, running Debian Linux (ami-116d857a). I've attempted to note the AWS-specific and Debian-specific parts. I was ssh'd in as the admin user; by default, that user has the right to use sudo without supplying a password.
Fix /etc/hosts (AWS specific; possibly Debian under AWS specific)
I tripped over a mildly annoying mis-configuration; sudo tries to resolve the machine's host name, and AWS doesn't provide a DNS mapping for it. This is entirely cosmetic; if you skip this step, all that will happen is that sudo will complain, but still work properly. But it complains every single time you use it. This annoyed me beyond toleration, so I fixed it.
One line summary of the fix: add an entry to /etc/hosts for the machine's hostname.
This is the only time in these instructions when I actually switched to running as root, rather than using sudo. The reason for doing so here is that the admin user doesn't have rights to write to /etc/passwd, so just running sudo echo >>/etc/hosts ...
doesn't work; the shell attempts to do the output redirection before exec-ing the sudo command, the output redirect fails, and therefore so does the command. It's possible to use the shell's quoting characters (", ', and/or \) to deal with this, but it's not straightforward, and I just couldn't be bothered. (I had my fill of arcane shell escaping about three decades ago. Much simpler to just switch to root for a moment.)
Make extremely sure that you use two > symbols, not one. Using two appends to /etc/hosts; using one will overwrite it. Overwriting it is Very Bad; the machine won't be able to resolve localhost, and all kinds of things will malfunction.
The string "ip-172-30-1-89" is the hostname of the machine I tested these on; you must substitute the correct hostname of the machine you're using. If you don't do this, the whole exercise is pointless.
sudo su -
echo >>/etc/hosts 127.0.0.1 ip-172-30-1-89
exit
Update the package manager's repository information
As with most distributions, Debian's state changes daily. It is thus important to bring it up to date before anything else. This will generally be necessary on any distribution, but the commands may be different.
There are two steps to this; the first command brings the package manager's repository information up to date, and the second one updates any actual packages that are out of date.
The -y and -q options are simply there to tell apt-get to just do what I ask for, without asking me for confirmation, and without nattering at me excessively (it still talks too much with -q, but it's not as bad).
sudo apt-get -y -q update
sudo apt-get -y -q upgrade
Install git
Now that we've finished all of the necessary AWS and Debian housekeeping, it's time to actually start installing the packages we need. First up is git, so we can access the YASW repository.
sudo apt-get -y -q install git
Install node-js
This is the actual node interpreter. I installed the full development version of node, 'nodejs-dev', which includes the files and other packages necessary to build node extension packages. This is probably overkill here; installing 'nodejs' would likely do the job. I didn't check.
sudo apt-get -y -q install nodejs-dev
Fix the node command (Debian specific)
There's a name collision to deal with here. Debian has a package called 'node', which greatly predates node-js (it's an amateur radio program, in case you were curious). Unfortunately, the old node package also installs a binary called 'node'. This means that node-js can't use that name for its executable without clobbering the amateur radio package (if it's installed). Debian deals with this by installing the node-js binary under the name 'nodejs'. This breaks lots of things in the node-js ecosystem, including Grunt (which is why it's a problem for us).
The way to fix this, without confusing Debian, is to run the command
sudo update-alternatives --install /usr/bin/node node /usr/bin/nodejs 10
Now typing 'node' will run the nodejs interpreter.
Install npm (Debian specific)
Debian splits npm, the node package manager, off into a seperate apt package. Normally, npm is part of the node bundle (it certainly is if you install from source), but for some reason, Debian doesn't do things that way.
sudo apt-get -y -q install npm
Install the command line interface for Grunt
This does not install Grunt, just the command-line wrapper for running it. We'll pick up Grunt itself a bit later when we install the dependencies for YASW. The -g option installs the wrapper globally, so it ends up in the command path.
sudo npm install -g grunt-cli
Grab the source code for YASW
The URL here is to clone the YASW repository via SSL. This means you won't be able to push changes back to the Github repository. If you have permission from us, or if you're working from a fork, you should use the appropriate URL to clone via the git protocol.
git clone https://github.com/JeffWaltzer/yasw-server.git
Pull in the npm packages that the YASW server code needs
cd yasw-server
npm install
Fire up the server
cd ../server
node yasw
This will give you a YASW server, listening on port 3000, and logging to stdout. Note that the AWS security group you're using must be set up to allow access to that port, or your requests won't ever get to the server.
Play!
Point a web browser at port 3000 on the server.
Copy the client files that the server needs to serve up over to the server's public directory
The server comes with a version of the YASW client already present, which is why you were able to run the program. If you change the client, or write a new one, you will need to copy the client's release code to the server's public
folder.