Giter Club home page Giter Club logo

ukforeignoffice.loi-submission-service's Introduction

is-submission-service

Processes message queue items placed by is-application-service. Sends the request to the Iizuka legalisation service.

Build Status

Server Prerequisites

  • 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++
```

* PostgreSQL - This can be installed on Ubuntu with apt-get

*  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
```

See some tips [here](https://www.digitalocean.com/community/tutorials/how-to-install-and-use-postgresql-on-ubuntu-14-04) on getting started with posgres. Also you probably want to set up md5 (password) authentication. Have a look [here](http://stackoverflow.com/questions/18664074/getting-error-peer-authentication-failed-for-user-postgres-when-trying-to-ge) for the basic idea.

A script containing a backup test copy of the database can be found within the project in the test/files [here](/test/files/FCO_LOI_Service_Test.sql). Do not modify this file as it will affect the outcome of the Mocha tests. It can be restored via command line like so:
```
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
    • RabbitMQ Management Plugin will help you manage the queues. More into here
    • rabbitmqadmin is a useful command line tool - more info here

Tools Prerequisites

Server

  • NPM - Node.js package manage; should be installed when you install node.js.

Additional Server Packages

All of the server package dependencies are defined in the package.json file. These can be installed by simply running

$ npm install

Some examples:

Service Configuration

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

Environmental Settings

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

Running the service

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

ukforeignoffice.loi-submission-service's People

Contributors

cmcgandy avatar martincarson avatar simonmoore100 avatar smulvenna avatar trevorrea avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.