1.5.0 • Published 7 years ago

@kobionic/node-config-server v1.5.0

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
7 years ago

Node Config Server

npm version Build Status Dependencies Status DevDependencies Status License

Centralized configuration server providing a dynamic RESTful API, allowing retrieval of entire files content or their parsed properties.

Installation

The Node Config Server project is deployed both on npm & the Docker Hub. Choose which type of installation meets your requirements and follow the appropriate procedure as described below.

npm

npm install --global @kobionic/node-config-server

Docker

Using plain-old Docker command

docker run -d --name node-config-server kobionic/node-config-server

The image basically exposes port 20490, therefore container links will make it available to the linked containers.

If you want to make it available to services running on your host, use the -p options to publish the port on your host:

docker run -d -p 20490:20490 --name node-config-server kobionic/node-config-server

Using Docker Compose

With Docker Compose, configuration is as easy as writing a docker-compose.yml file such as:

version: '3'

services:
  node-config-server:
    image: 'kobionic/node-config-server'
    container_name: 'node-config-server'
    restart: 'always'
    ports:
      - '20490:20490'
    volumes:
      - '/path/to/your/config:/app/config:ro'

Configuration

Configuration of the application is done using environment variables. You can find a list of all available variables by reading this documentation a little bit further.

Configure with Docker Compose

Configuring the application with Docker Compose only requires adding an environment array to your docker-compose.yml file.

As an example, if you would like to set the maximum number of forks to create when instantiating the server to 2 and add a correlation ID to the logger, you need to add this to your docker-compose.yml file:

environment:
  CPUS_NUMBER: 2
  LOG_PRINT_ID: 'true'

Configure by setting OS environment variables

Let's use the example above again and set CPUS_NUMBER to 2 and LOG_PRINT_ID to true using environment variables, both on Linux & Windows.

On Linux

export CPUS_NUMBER=2
export LOG_PRINT_ID=true

On Windows

set CPUS_NUMBER=2
set LOG_PRINT_ID=true

Environment variables

Numerous environment variables can be set to configure the application.

VariableTypeDefaultDescription
PORTnumber20490the port the server will listen on
CPUS_NUMBERnumberOS core numbernumber of servers to instantiate using the Node.js cluster API
LOG_DIRstring./logslog file directory
LOG_LEVELstringinfoset the logging level ( debug | error | info | none )
LOG_NAMEstringnode-config-serverlog file name
LOG_PRINT_IDbooleanfalseif set to true, will add a correlation ID to the logging output
NODE_CONFIG_DIRstring./configbase directory where served files will be looked for
EUREKA_CLIENTbooleanfalsethe server will try to register to an Eureka server if set to true
EUREKA_SERVER_HOSTstringlocalhostconfigures the Eureka server hostname
EUREKA_SERVER_PORTnumber8761configures the Eureka server port number

Authors

License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.