-
Notifications
You must be signed in to change notification settings - Fork 0
Setup
This setup page assumes that you have to completely install and setup the application in its entirety. This assumes that you are hosting this on a Linux server (Ubuntu was used for our setup) and have already installed a Nginx server but have yet to actually proxy your DNS website to the locally hosted website.
You can also use the included scripts for handling all of the steps after the project has been cloned and the configuration files and directories have been setup with the libraries. After step 7, simply run the included setup.sh script from the root directory by using
. ./setup.sh
This will setup all the needed environment variables, install the npm packages, make the needed symlinks, and build the go executable.
Setup Steps
- You will need to install Go, Node.js and its package manager NPM, and Postgres database management system. You can do this in a variety of ways but the easiest would be to simply use
apt-get install <package name>. - Setup the Postgres database. You will need to setup the main user settings and a new database. You can find a quick and easy reference here but in essence you will need to do
sudo -U postgres psql postgres
\password postgres(in Postgres client that has popped up)
\q(quit the Postgres client)
sudo -U postgres createdb mydb(exchange mydb with wanted DB name)
psql -h localhost -d mydb -U postgres -f /path/to/backup.sql(to import the db from given backup.sql file, which is found in thesrc/app/databasedirectory) - You have your DB now setup, next you will need to clone the repository onto your server using git. This must be done, if using our configuration, in the
/www/directory of the DM server, that way you can get the Nginx server to reach it. You may also need to change the file permissions once cloned so that the Nginx process has access to that directory. - Once cloned, you will need to grab the libraries mentioned in the README. These are important as the newly updated libraries are incompatible with the app, these deprecated ones are a workaround. Place these libraries in their specified locations from the README.
- Install all the necessary node packages by running
npm installinside of thesrc/app/webappdirectory. - You will need to run the included script
make_symlinks.shfrom thesrc/app/missiondm_server/jsafter settings the variables for$ASSPATHusingexport ASSPATH=/path/to/src/app/. This command will create necessary symlinks from the webapp directory min.js distributions and place them into the missiondm_server directory. Don't worry about exactly what that means. - Setup your
config.jsandconfig.jsonfiles from the templates. Make sure you have them ignored from being pushed up to Github (they should be auto ignored in the .gitignore file). - Now you will need to build the go server. Before you can use go, you will need to setup a variable called GOPATH in bash that tells the terminal cli where the app is in reference to the Go executable. All you need to do is go to the root folder, which has the
src/directory, and runexport GOPATH=$(pwd). After this has been completed, rungo envand look for the definition set for GOPATH. It should point to the application's root folder. - Now that your path is set, cd into the
src/app/missiondm_serverdirectory and rungo build. This should build the go server executable in this directory. - You have everything you need to run the app. Now if you run the Go server (which we will get into later in this page) and setup the Nginx configuration to display the the MissionDM website on port 80, we should be able to see the site and play MissionDM!
If you want people to access the application from the purchased domain, i.e. missiondm.org or what have you, you will need to add a section into your nginx or apache server that proxies connections from that web address to the local port that the frontend website is running on.
Nginx Setup
We will be using nginx in this case. This configuration can be simply done by editing the default server configuration in your /etc/nginx/sites-available directory (or wherever your nginx configuration files are located). You will simply need to add this to the sites-available/default server configuration (in its own section preferably below the previous existing server definitions). Here is the basic one we have been using, which you can feel free to replicate if something needs to be changed:
# MissionDM Server
server {
listen 80;
server_name missiondm.org;
index index.html index.htm;
# Set location for serving files
location / {
root /www/MissionDM/src/app/webapp;
try_files $uri $uri/ /index.html;
}
# Error Handling
error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/www;
}
}
and then use the nginx -s reload command to reset nginx and have your server start proxying connections from your website to the intended port.
You can find a great reference for this here
DNS Setup
There is also a trick to setting up your domain so that it points specfically to the intended ip and is proxied to the port by our now updated nginx server. You will need to login to the website of the provider you purchased your domain from, and then go to the Manage DNS settings of your purchased domain.
You will need to add what is call an A record to the DNS settings of your site, this allows the site to forward its access to a different website. Either add a new A record or edit the previous one and set its settings to
| Record | Hostname | Value |
|---|---|---|
| A | @ | ip.of.server |
and now the forwarding should begin. This may take up to 24 hours based on your provider so do not fret if the transition is not instant.
You will also need to edit some CNAME records here in order for the mailgun setup to word correctly but you can find more information on that in the mailgun reference docs.
To have the server simply start and stop when the Ubuntu server launches, you will need to create what is called an Upstart Event
To do this, simply follow the setups in the above link:
- Create a new config file in
/etc/init/and call it whatever, in this case I called itmissiondm_server.conf - Denote in this config file the startup and takedown operations you want to have happen. This will occur when the server launches and closes, just to ensure that it closes safely.
You can use the example one that I have already set up on the DM server if you ever need to recreate it:
Filename: missiondm_server.conf
# Service to run MissionDM Server
description "MissionDM Server"
author "R. Alex Clark <github/aclark2089>"
# Startup
start on runlevel [2345]
stop on runlevel [016]
# Respawn the server indefinitely
respawn
respawn limit unlimited
# Output to Console
console output
# Startup script
chdir /www/MissionDM/src/app/missiondm_server
exec ./missiondm_server
Now you can simply launch or close the server using
sudo service missiondm_server start to start the server
sudo service missiondm_server stop to stop the server