@kobionic/node-config-server
v1.5.0
Published
Centralized configuration server providing a dynamic RESTful API, allowing retrieval of entire files content or their parsed properties.
Downloads
30
Maintainers
Readme
Node Config Server
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.
| Variable | Type | Default | Description |
| -------------------- | ------- | ------------------ | ------------------------------------------------------------------------ |
| PORT
| number | 20490 | the port the server will listen on |
| CPUS_NUMBER
| number | OS core number | number of servers to instantiate using the Node.js cluster API |
| LOG_DIR
| string | ./logs | log file directory |
| LOG_LEVEL
| string | info | set the logging level ( debug | error | info | none ) |
| LOG_NAME
| string | node-config-server | log file name |
| LOG_PRINT_ID
| boolean | false | if set to true, will add a correlation ID to the logging output |
| NODE_CONFIG_DIR
| string | ./config | base directory where served files will be looked for |
| EUREKA_CLIENT
| boolean | false | the server will try to register to an Eureka server if set to true |
| EUREKA_SERVER_HOST
| string | localhost | configures the Eureka server hostname |
| EUREKA_SERVER_PORT
| number | 8761 | configures the Eureka server port number |
Authors
- Jeremie Rodriguez <[email protected]> - Main developer
License
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.