4.0.2 • Published 12 months ago

af-consul v4.0.2

Weekly downloads
-
License
ISC
Repository
github
Last release
12 months ago

Not of interest to third party users

Example of settings for registering a service

const registerOptions = {
    name: 'service name',       // (String): service name
    id: 'service ID',           // (String, optional): service ID
    tags: ['tag1'],            // (String[], optional): service tags
    address: '0.0.0.0',        // (String, optional): service IP address
    port: 9602,                // (Integer, optional): service port
    meta: {},                  // (Object, optional): metadata linked to the service instance
    check: {                   // (Object, optional): service check
        http: '',              // (String): URL endpoint, requires interval
        tcp: '',               // (String): host:port to test, passes if connection is established, fails otherwise
        script: '',            //  (String): path to check script, requires interval
        dockercontainerid: '', //  (String, optional): Docker container ID to run script
        shell: '',             //  (String, optional): shell in which to run script (currently only supported with Docker)
        interval: '',          //  (String): interval to run check, requires script (ex: 15s)
        timeout: '',           //  (String, optional): timeout for the check (ex: 10s)
        ttl: '',               //  (String): time to live before check must be updated, instead of http/tcp/script and interval (ex: 60s)
        notes: '',             //  (String, optional): human readable description of check
        status: '',            //  (String, optional): initial service status
        deregistercriticalserviceafter: '' //  (String, optional, Consul 0.7+): timeout after which to automatically deregister service if check remains in critical state
    },
    checks: [{}],              //  (Object[], optional): service checks (see check above)
    connect: {},               // (Object, optional): specifies the configuration for Connect
    proxy: {},                 // (Object, optional): specifies the configuration for a Connect proxy instance
    taggedAddresses: {}        // (Object, optional): specifies a map of explicit LAN and WAN addresses for the service instance
};

Usage example

import 'dotenv/config';
import os from 'os';
import { logger } from './logger';
import { getAPI } from '../src';

const e = process.env;
const config = {
  consul: {
    check: {
      interval: e.CONSUL_HEALTH_CHECK_INTERVAL || '1s',
      timeout: e.CONSUL_HEALTH_CHECK_TMEOUT || '1s',
      deregistercriticalserviceafter: e.CONSUL_DEREGISTER_CRITICAL_SERVICE_AFTER || '1m',
    },
    agent: {
      reg: {
        host: e.CONSUL_AGENT_HOST || thisHostName,
        port: e.CONSUL_AGENT_PORT || '8500',
        secure: e.CONSUL_AGENT_SECURE,
        token: e.CONSUL_AGENT_TOKEN,
      },
      dev: {
        dc: e.CONSUL_AGENT_DEV_DC || 'dc-dev',
        host: e.CONSUL_AGENT_DEV_HOST || thisHostName,
        port: e.CONSUL_AGENT_DEV_PORT || '8500',
        secure: e.CONSUL_AGENT_DEV_SECURE,
        token: e.CONSUL_AGENT_DEV_TOKEN,
      },
      prd: {
        dc: e.CONSUL_AGENT_PRD_DC || 'dc-prd',
        host: e.CONSUL_AGENT_PRD_HOST || thisHostName,
        port: e.CONSUL_AGENT_PRD_PORT || '8500',
        secure: e.CONSUL_AGENT_PRD_SECURE,
        token: e.CONSUL_AGENT_PRD_TOKEN,
      },
    },
    // Details of the service being registered with consul
    service: {
      name: e.CONSUL_SERVICE_NAME || 'af-consul',
      instance: e.CONSUL_SERVICE_INSTANCE || 'test',
      version: e.CONSUL_SERVICE_VERSION || '0.0.1',
      description: e.CONSUL_SERVICE_DESCRIPTION || 'AF-CONSUL TEST',
      tags: e.CONSUL_SERVICE_TAGS || ['af', 'consul', 'test'],
      meta: e.CONSUL_SERVICE_META || { CONSUL_TEST: 12345, line_yellow: 'straight' },
      host: e.CONSUL_SERVICE_HOST || null,
      port: e.CONSUL_SERVICE_PORT || null,
    },
  },
  webServer: {
    host: e.WS_HOST || '0.0.0.0',
    port: e.WS_PORT || '10000',
  },
}

Идентификаторы отладки

AP-UPDATER       - access-points-updater:   
      - Polling ${CONSUL_ID}   
      - The data is up-to-date ${CONSUL_ID}

af-consul 		 
    `${yellow} REGISTER CONFIG:\n${JSON.stringify(registerConfig, undefined, 2)}\n${reset}`
    `CONSUL AGENT OPTIONS:\n${JSON.stringify(fullConsulAgentOptions, undefined, 2)}`
    `${rqId}HTTP Status: ${statusCode}`
    `${rqId}res.body not found! res: ${res}`
    `No info about service ID ${cyan}${serviceName}`
    `${prefixG} Skip registration check after health check`    

af-consul:curl
    const msg = dbg.curl ? getCurl(request, true) : getHttpRequestText(request);
    `[${request._id_}] ${yellow}${msg}${reset}`

af-consul:reg
    `${PREFIX}: updated ${updatedCount.length} access point(s)`
    `${prefixG} Service ${cyan}${registerConfig.id}${reset} registration check...`
4.0.2

12 months ago

3.0.42

12 months ago

3.0.41

2 years ago

3.0.40

2 years ago

3.0.23

2 years ago

3.0.24

2 years ago

3.0.27

2 years ago

3.0.25

2 years ago

3.0.26

2 years ago

3.0.34

2 years ago

3.0.35

2 years ago

3.0.32

2 years ago

3.0.33

2 years ago

3.0.38

2 years ago

3.0.39

2 years ago

3.0.36

2 years ago

3.0.37

2 years ago

3.0.29

2 years ago

3.0.22

2 years ago

3.0.20

2 years ago

3.0.19

2 years ago

3.0.17

2 years ago

3.0.15

2 years ago

3.0.18

2 years ago

3.0.12

3 years ago

3.0.10

3 years ago

3.0.14

3 years ago

3.0.8

3 years ago

3.0.7

3 years ago

3.0.6

3 years ago

3.0.5

3 years ago

3.0.4

3 years ago

3.0.3

3 years ago

3.0.2

3 years ago

2.0.27

3 years ago

2.0.26

3 years ago

2.0.25

3 years ago

2.0.24

3 years ago

2.0.23

3 years ago

2.0.22

3 years ago

2.0.21

3 years ago

2.0.20

3 years ago

2.0.19

3 years ago

2.0.18

3 years ago

2.0.17

3 years ago

2.0.16

3 years ago

2.0.15

3 years ago

2.0.14

3 years ago

2.0.13

3 years ago

2.0.11

3 years ago

2.0.10

3 years ago

2.0.9

3 years ago

2.0.7

3 years ago

2.0.6

3 years ago

2.0.4

3 years ago

2.0.3

3 years ago

2.0.2

4 years ago

1.1.11

4 years ago

1.1.9

4 years ago

1.1.7

4 years ago

1.1.6

4 years ago

1.1.5

4 years ago

1.1.4

4 years ago

1.1.3

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.0.100

4 years ago

1.0.99

4 years ago

1.0.98

4 years ago

1.0.97

4 years ago

1.0.95

4 years ago

1.0.94

4 years ago

1.0.93

4 years ago

1.0.91

4 years ago

1.0.90

4 years ago

1.0.88

4 years ago

1.0.87

4 years ago

1.0.86

4 years ago

1.0.85

4 years ago

1.0.84

4 years ago

1.0.83

4 years ago

1.0.82

4 years ago

1.0.81

4 years ago

1.0.80

4 years ago

1.0.76

4 years ago

1.0.68

4 years ago

1.0.65

4 years ago

1.0.63

4 years ago

1.0.62

4 years ago

1.0.61

4 years ago

1.0.60

4 years ago

1.0.59

4 years ago

1.0.58

4 years ago

1.0.57

4 years ago

1.0.56

4 years ago

1.0.54

4 years ago

1.0.53

4 years ago

1.0.52

4 years ago

1.0.49

4 years ago

1.0.48

4 years ago

1.0.47

4 years ago

1.0.46

4 years ago

1.0.45

4 years ago

1.0.44

4 years ago

1.0.43

4 years ago

1.0.42

4 years ago

1.0.41

4 years ago

1.0.40

4 years ago

1.0.39

4 years ago

1.0.38

4 years ago

1.0.37

4 years ago

1.0.36

4 years ago

1.0.35

4 years ago

1.0.34

4 years ago

1.0.33

4 years ago

1.0.32

4 years ago

1.0.31

4 years ago

1.0.30

4 years ago

1.0.28

4 years ago

1.0.27

4 years ago

1.0.26

4 years ago

1.0.25

4 years ago

1.0.24

4 years ago

1.0.23

4 years ago

1.0.22

4 years ago

1.0.21

4 years ago

1.0.20

4 years ago

1.0.19

4 years ago

1.0.18

4 years ago

1.0.17

4 years ago

1.0.16

4 years ago

1.0.12

4 years ago

1.0.5

4 years ago