Processes message queue items placed by is-application-service. Sends the request to the Iizuka legalisation service.
- Node.js - You can download and install the LTS version of node using apt-get
```
curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
```
```
sudo apt-get install --yes nodejs
```
Some node packages rely on the g++ compiler
```
sudo apt-get install g++
```
* You can install PostgreSQL 9.3 using the command
```
sudo apt-get install postgresql-9.3
```
* Set root user credentials
```
sudo -u postgres psql
```
Then set root user credentials using the command
```
ALTER USER postgres PASSWORD 'newpassword';
```
You can now exit the PostgreSQL shell using the command quit.
Henceforth you can login to the PostgreSQL shell using the command
```
psql -U postgres -h localhost
```
and the password you set in the previous step using the login password.
* Install pgAdmin (optional)
This is a graphical tool that makes it easy to perform a number of administratove tasks. To install pgAdmin, use the command
```
sudo apt-get install pgadmin3
```
```
PGPASSWORD=xxxxxx psql -U postgres -1 -f test/files/FCO_LOI_Service_Test.sql
```
- RabbitMQ - used for asynchronous processing of requests from the is-application-service see installation instructions here
- NPM - Node.js package manage; should be installed when you install node.js.
All of the server package dependencies are defined in the package.json file. These can be installed by simply running
$ npm install
Some examples:
- Express - web framework for Node. More information [here] (http://expressjs.com/).
- amqplib - provides access to RabbitMQ. More information [here] (http://www.squaremobius.net/amqp.node/channel_api.html).
- Sequalize - a NodeJS ORM for postgreSQL. More information [here] (http://docs.sequelizejs.com/en/latest/).
All server configuration is specified in the ./server/config folder, through the ./server/config/env/ files. Here you will need to specify your MongoDb, RabbitMQ and postgreSQL parameters. See the /server/config/env folder and /server/config/config.js file for the various environments. The server is run on any port by setting the process.env.PORT variable before starting the service. See examples in /package.json
There are five environments currently provided: debug, staging. development, test, testi (integration testing) and production.
To run with a different environment, just specify NODE_ENV as you call node:
$ NODE_ENV=test node server/bin/www
Once you have installed the dependencies with npm install, it is probably a good idea to run the unit tests (they are run on port 6000 by default)
$ npm test
To run units tests with code coverage information, run
$ npm run coverage
Then have a look at the html pages generated at
coverage/lcov-report/index.html
Then you can start the server using
$ node server/bin/www
or if you want to run as a daemon you can add a .conf file the /etc/init folder
$ sudo nano /etc/init/fco-loi-submission.conf
Here is an example of what this file might look like:
description "FCO LOI Submission Service"
start on (filesystem and net-device-up IFACE=lo)
stop on runlevel [!2345]
respawn
env port=3005
env NODE_ENV=testi
chdir /home/fcoloi/services/submission/is-submission-service/server
exec nodejs bin/www
Then you can start the server by running
$ sudo service fco-loi-submission start
to stop the service running instances in forever:
$ sudo service fco-loi-submission stop