Grab the dependencies by running the script for your platform in
installers/
. If you're doing this on a development machine, you probably want
to review the installers first and remove any dependencies you already have
installed (don't worry, they're short!)
-
OS X: Uses homebrew to install the dependecies.
-
Ubuntu: Uses apt-get
-
Windows:
- Ensure powershell is installed, then run install.bat as Admin
- After the install has completed, setup the application with:
cd server/ && npm run-script setup
Your application needs configuration files for the environment it will be run in. View the configuration README for possible options.
Install the application on windows as a service using NSSM. Configure NSSM as such:
- Path: C:\Path\To\node.exe
- Startup Directory: C:\Path\To\NRT\server
- Options: .\bin\server.js
Port all your IO to NRT\server\logs\service.log to be able to read STDOUT/ERR messages
NODE_ENV=production
AUTH_TOKEN=changeme
PORT=80
If you're intending to use this deployment for automated deploy, check that your environment variables are setup for the SYSTEM user which which will run the service. Otherwise, your deploy will fail with missing commands.
In development, supervisor is used to handle exceptions:
cd server/ && npm start
For more info, check out the asset README.
cd client && grunt && grunt watch
In development, the users will be seeded on application boot. To login,
pick a user from server/lib/users.json
, e.g.
[email protected]
password
Data is seeded and updated from the /admin route. If you wish to add new indicators, or update the existing ones, have a look at the Indicatoration documentation. If backup data is ok, just click 'Seed from backup'
There is a JSON Generator script which
generates data in the same format as the indicator data backup in
server/lib/indicator_data.json
. To generate fake data backups:
- Grab the contents of the file and enter it into the JSON generator
- Save the generated output to the backup file at
server/lib/indicator_data.json
- Seed from backup by visiting
/admin
and clicking 'seed from backup'
Windows
cd server
npm run-script win-production
Unix
cd server/ && npm run-script production
For more info, check out the asset README.
cd client && grunt
In production, no users are seeded and have to be created manually. However, you can use an LDAP server for authentication once it has been configured. Note that for EAD LDAP use, you must be within the EAD VPN.
NRT can connect to a LDAP to authenticate and create users.
LDAP is configured by the file server/config/ldap.json
, and an example
can be found in server/config/ldap.json.example
. See the deployment secrets
document
for the production details you need.
LDAP is a optional feature which can be disabled in the application config: https://github.com/unepwcmc/NRT/tree/master/server/config#example
When running NRT in a UNIX environment, it might be useful to use UNIX sockets instead of ports, in order to have a more descriptive access point to the NRT instance. A reverse proxy can then be set to listen on the newly created socket. Here we provide a configuration example to setup an NRT server running behind nginx, the popular high-performance HTTP server and reverse proxy.
NRT configuration file
{
"server": {
"name": "production-1",
"use_unix_sockets": true
}
}
Firing up NRT with this configuration file will create a UNIX socket located at
/tmp/production-1.sock
. Note how the UNIX socket takes its name from the
server.name
attribute defined in the configuration file.
To listen on the newly created socket, configure nginx appropriately. Here, we use the common sites-enabled/sites-available paradigm, and create a new configuration file called nrt-production-1 in the sites-available folder.
server {
listen 0.0.0.0:80;
server_name production-1.nrt.io nrt-production-1;
access_log /var/log/nginx/nrt-production-1.log;
# pass the request to the node.js server with the correct headers and much more can be added, see nginx config options
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://unix:/tmp/production-1.sock:/;
proxy_redirect off;
}
}
After restarting nginx, accessing production-1.nrt.io
will connect to
nginx, thus the production-1 UNIX socket and the underlying node server.