Server-side implementation for LMNO games. This repository contains the server-side implementation for a number of games that are hosted at the https://lmno.games/ website. Dependencies ------------ This implementation requires nodejs which can be installed (on a Debian system at least) with: sudo apt-get install nodejs Additionally, you'll need to make available a number of third part node libraries. This is most convenient to by using npm which can be done as follows: sudo apt-get install npm # To install npm install npm install # To install dependencies into node_modules Deployment ---------- The initial deployment of the LMNO server requires configuring a web server. Instructions are provided below for any web server, along with specific configuration examples for Apache. If you are using a non-Apache server (such as nginx) the general concepts will still apply, but the syntax of the configuration will be different. First, you need to configure your web server to serve the static content of the LMNO implementation. This static content is actually in a separate git repository (lmno.games) which you should be able to find near where you found the current repository (lmno-server). So, first, copy the static files from the lmno.games repository to your server (there's a "make deploy" target in the lmno.games repository's Makefile that can help with this). Then, configure your web server to serve the content that you have deployed. Specifically, you want the server to match the path from the request to the local filesystem and serve the local file whenever there is a match. The syntax for this with Apache is as follows (substitute the path you chose if anything other than "/srv/lmno.games/www"): DocumentRoot /srv/lmno.games/www Options Indexes Require all granted RewriteEngine on # Any static files (or directories) that exist within the # DocumentRoot are served directly by Apache as a first priority. RewriteCond %{DOCUMENT_ROOT}/$1 -f [OR] RewriteCond %{DOCUMENT_ROOT}/$1 -d RewriteRule (.*) - [L] Note: The above configuration requires both the "rewrite" and "proxy" and "proxy_http" Apache modules to be installed and enabled. On some operating systems this can be achieved with the following commands: sudo a2enmod rewrite sudo a2enmod proxy sudo a2enmod proxy_http Also, you will need to configure Apache to proxy to the node server any requests that _don't_ match a static file. Assuming you're running the LMNO node server on port 4000 (which the code currently defaults to) you would add the following Apache configuration just after the block above: # Otherwise, for any path that does not exist in the filesystem # we proxy to the dynamic web app to let it serve the resource. RewriteRule ^/(.*)$ http://localhost:4000/$1 [P] ProxyPassReverse / http://localhost:4000 And, of course, after changing Apache configuration, you'll need to restart the Apache service. Finally, you'll need to arrange to start the node process on port 4000 that will serve the dynamic LMNO content. This is as simple as running: node lmno Which must be run from the directory containing the lmno.js file. And of course, this could be wired into an lmno service to enable this to be started each time the machine boots. Once this configuration is complete and working, any updates to the code will simply requiring terminating the node process and then starting it up again. Development ----------- For testing changes to the implementation locally, we recommend doing the exact same deployment described above on a local machine, (that is, configure a web server to serve static content from the lmno.games repository and to proxy dynamic content to the node process). You might simply configure and access this at http://localhost/ if you're not already using a local web server for any other purpose. Otherwise, configure your webserver with whatever hostname and top-level path you prefer.