@tramvai/module-server 2.39.2 → 2.40.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -218,6 +218,27 @@ Or use env variable `UTILITY_SERVER_PORT` with defined value.
218
218
  env UTILITY_SERVER_PORT=6532 tramvai start app
219
219
  ```
220
220
 
221
+ ### Specify path for liveness and readiness probes
222
+
223
+ By default, liveness and readiness probes are available by `healtz` and `readyz` paths.
224
+
225
+ If you want to change this paths, use `LIVENESS_PATH_TOKEN` and `READINESS_PATH_TOKEN` tokens.
226
+
227
+ ```ts
228
+ import { LIVENESS_PATH_TOKEN, READINESS_PATH_TOKEN } from '@tramvai/tokens-server';
229
+
230
+ const providers = [
231
+ {
232
+ provide: LIVENESS_PATH_TOKEN,
233
+ useValue: '/custom-liveness',
234
+ },
235
+ {
236
+ provide: READINESS_PATH_TOKEN,
237
+ useValue: '/custom-readiness',
238
+ },
239
+ ];
240
+ ```
241
+
221
242
  ## Exportable tokens
222
243
 
223
244
  [Link](references/tokens/server.md)
package/lib/server.es.js CHANGED
@@ -2,7 +2,7 @@ import { __decorate } from 'tslib';
2
2
  import { setDefaultResultOrder } from 'dns';
3
3
  import EventEmitter$1, { EventEmitter } from 'events';
4
4
  import { Scope, APP_INFO_TOKEN, Module, provide as provide$1, DI_TOKEN as DI_TOKEN$1, COMMAND_LINE_RUNNER_TOKEN, commandLineListTokens, createToken } from '@tramvai/core';
5
- import { SERVER_MODULE_PAPI_PUBLIC_ROUTE, SERVER_MODULE_PAPI_PUBLIC_URL, SERVER_MODULE_PAPI_PRIVATE_URL, SERVER_MODULE_PAPI_PRIVATE_ROUTE, SERVER_MODULE_STATICS_OPTIONS, SERVER_TOKEN, READINESS_PROBE_TOKEN, LIVENESS_PROBE_TOKEN, UTILITY_SERVER_PATHS, PROXY_CONFIG_TOKEN, DEPENDENCIES_VERSION_FILTER_TOKEN, UTILITY_SERVER_PORT_TOKEN } from '@tramvai/tokens-server';
5
+ import { SERVER_MODULE_PAPI_PUBLIC_ROUTE, SERVER_MODULE_PAPI_PUBLIC_URL, SERVER_MODULE_PAPI_PRIVATE_URL, SERVER_MODULE_PAPI_PRIVATE_ROUTE, SERVER_MODULE_STATICS_OPTIONS, SERVER_TOKEN, LIVENESS_PATH_TOKEN, READINESS_PATH_TOKEN, READINESS_PROBE_TOKEN, LIVENESS_PROBE_TOKEN, UTILITY_SERVER_PATHS, PROXY_CONFIG_TOKEN, DEPENDENCIES_VERSION_FILTER_TOKEN, UTILITY_SERVER_PORT_TOKEN } from '@tramvai/tokens-server';
6
6
  export * from '@tramvai/tokens-server';
7
7
  import { FASTIFY_REQUEST, FASTIFY_RESPONSE, PAPI_EXECUTOR, WEB_FASTIFY_APP_BEFORE_INIT_TOKEN, UTILITY_WEB_FASTIFY_APP_TOKEN, WEB_FASTIFY_APP_INIT_TOKEN, UTILITY_SERVER_TOKEN, SERVER_FACTORY_TOKEN, WEB_FASTIFY_APP_TOKEN, WEB_FASTIFY_APP_FACTORY_TOKEN, WEB_FASTIFY_APP_AFTER_INIT_TOKEN, WEB_FASTIFY_APP_METRICS_TOKEN, WEB_FASTIFY_APP_LIMITER_TOKEN, WEB_FASTIFY_APP_BEFORE_ERROR_TOKEN, WEB_FASTIFY_APP_PROCESS_ERROR_TOKEN, WEB_FASTIFY_APP_AFTER_ERROR_TOKEN } from '@tramvai/tokens-server-private';
8
8
  import { ROOT_EXECUTION_CONTEXT_TOKEN, RESPONSE_MANAGER_TOKEN, LOGGER_TOKEN, REQUEST_MANAGER_TOKEN, ENV_MANAGER_TOKEN, ENV_USED_TOKEN, EXECUTION_CONTEXT_MANAGER_TOKEN } from '@tramvai/tokens-common';
@@ -544,8 +544,6 @@ ServerStaticsModule = __decorate([
544
544
 
545
545
  const GRACEFUL_SHUTDOWN_TIMEOUT = 25000;
546
546
  const GRACEFUL_READINESS_TIMEOUT = 5000;
547
- const healthzPath = '/healthz';
548
- const readyzPath = '/readyz';
549
547
  const noopCheck = () => { };
550
548
  let ServerGracefulShutdownModule = class ServerGracefulShutdownModule {
551
549
  };
@@ -555,7 +553,7 @@ ServerGracefulShutdownModule = __decorate([
555
553
  provide$1({
556
554
  provide: WEB_FASTIFY_APP_BEFORE_INIT_TOKEN,
557
555
  multi: true,
558
- useFactory: ({ app, server, logger, commandLineRunner, livenessProbe, readinessProbe }) => {
556
+ useFactory: ({ app, server, logger, commandLineRunner, livenessPath, readinessPath, livenessProbe, readinessProbe, }) => {
559
557
  const log = logger('server');
560
558
  return function serverListen() {
561
559
  createTerminus(server, app, {
@@ -591,8 +589,8 @@ ServerGracefulShutdownModule = __decorate([
591
589
  process.exit();
592
590
  },
593
591
  healthChecks: {
594
- [healthzPath]: livenessProbe || noopCheck,
595
- [readyzPath]: readinessProbe || noopCheck,
592
+ [livenessPath]: livenessProbe || noopCheck,
593
+ [readinessPath]: readinessProbe || noopCheck,
596
594
  },
597
595
  });
598
596
  };
@@ -602,15 +600,40 @@ ServerGracefulShutdownModule = __decorate([
602
600
  server: SERVER_TOKEN,
603
601
  logger: LOGGER_TOKEN,
604
602
  commandLineRunner: COMMAND_LINE_RUNNER_TOKEN,
603
+ livenessPath: LIVENESS_PATH_TOKEN,
604
+ readinessPath: READINESS_PATH_TOKEN,
605
605
  readinessProbe: { token: READINESS_PROBE_TOKEN, optional: true },
606
606
  livenessProbe: { token: LIVENESS_PROBE_TOKEN, optional: true },
607
607
  },
608
608
  }),
609
- {
609
+ provide$1({
610
+ provide: LIVENESS_PATH_TOKEN,
611
+ useValue: '/healthz',
612
+ }),
613
+ provide$1({
614
+ provide: READINESS_PATH_TOKEN,
615
+ useValue: '/readyz',
616
+ }),
617
+ provide$1({
610
618
  provide: UTILITY_SERVER_PATHS,
611
- useValue: [readyzPath, healthzPath],
619
+ useFactory: ({ livenessPath }) => {
620
+ return livenessPath;
621
+ },
612
622
  multi: true,
613
- },
623
+ deps: {
624
+ livenessPath: LIVENESS_PATH_TOKEN,
625
+ },
626
+ }),
627
+ provide$1({
628
+ provide: UTILITY_SERVER_PATHS,
629
+ useFactory: ({ readinessPath }) => {
630
+ return readinessPath;
631
+ },
632
+ multi: true,
633
+ deps: {
634
+ readinessPath: READINESS_PATH_TOKEN,
635
+ },
636
+ }),
614
637
  ],
615
638
  })
616
639
  ], ServerGracefulShutdownModule);
package/lib/server.js CHANGED
@@ -566,8 +566,6 @@ ServerStaticsModule = tslib.__decorate([
566
566
 
567
567
  const GRACEFUL_SHUTDOWN_TIMEOUT = 25000;
568
568
  const GRACEFUL_READINESS_TIMEOUT = 5000;
569
- const healthzPath = '/healthz';
570
- const readyzPath = '/readyz';
571
569
  const noopCheck = () => { };
572
570
  let ServerGracefulShutdownModule = class ServerGracefulShutdownModule {
573
571
  };
@@ -577,7 +575,7 @@ ServerGracefulShutdownModule = tslib.__decorate([
577
575
  core.provide({
578
576
  provide: tokensServerPrivate.WEB_FASTIFY_APP_BEFORE_INIT_TOKEN,
579
577
  multi: true,
580
- useFactory: ({ app, server, logger, commandLineRunner, livenessProbe, readinessProbe }) => {
578
+ useFactory: ({ app, server, logger, commandLineRunner, livenessPath, readinessPath, livenessProbe, readinessProbe, }) => {
581
579
  const log = logger('server');
582
580
  return function serverListen() {
583
581
  terminus.createTerminus(server, app, {
@@ -613,8 +611,8 @@ ServerGracefulShutdownModule = tslib.__decorate([
613
611
  process.exit();
614
612
  },
615
613
  healthChecks: {
616
- [healthzPath]: livenessProbe || noopCheck,
617
- [readyzPath]: readinessProbe || noopCheck,
614
+ [livenessPath]: livenessProbe || noopCheck,
615
+ [readinessPath]: readinessProbe || noopCheck,
618
616
  },
619
617
  });
620
618
  };
@@ -624,15 +622,40 @@ ServerGracefulShutdownModule = tslib.__decorate([
624
622
  server: tokensServer.SERVER_TOKEN,
625
623
  logger: tokensCommon.LOGGER_TOKEN,
626
624
  commandLineRunner: core.COMMAND_LINE_RUNNER_TOKEN,
625
+ livenessPath: tokensServer.LIVENESS_PATH_TOKEN,
626
+ readinessPath: tokensServer.READINESS_PATH_TOKEN,
627
627
  readinessProbe: { token: tokensServer.READINESS_PROBE_TOKEN, optional: true },
628
628
  livenessProbe: { token: tokensServer.LIVENESS_PROBE_TOKEN, optional: true },
629
629
  },
630
630
  }),
631
- {
631
+ core.provide({
632
+ provide: tokensServer.LIVENESS_PATH_TOKEN,
633
+ useValue: '/healthz',
634
+ }),
635
+ core.provide({
636
+ provide: tokensServer.READINESS_PATH_TOKEN,
637
+ useValue: '/readyz',
638
+ }),
639
+ core.provide({
632
640
  provide: tokensServer.UTILITY_SERVER_PATHS,
633
- useValue: [readyzPath, healthzPath],
641
+ useFactory: ({ livenessPath }) => {
642
+ return livenessPath;
643
+ },
634
644
  multi: true,
635
- },
645
+ deps: {
646
+ livenessPath: tokensServer.LIVENESS_PATH_TOKEN,
647
+ },
648
+ }),
649
+ core.provide({
650
+ provide: tokensServer.UTILITY_SERVER_PATHS,
651
+ useFactory: ({ readinessPath }) => {
652
+ return readinessPath;
653
+ },
654
+ multi: true,
655
+ deps: {
656
+ readinessPath: tokensServer.READINESS_PATH_TOKEN,
657
+ },
658
+ }),
636
659
  ],
637
660
  })
638
661
  ], ServerGracefulShutdownModule);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tramvai/module-server",
3
- "version": "2.39.2",
3
+ "version": "2.40.0",
4
4
  "description": "",
5
5
  "browser": "lib/browser.js",
6
6
  "main": "lib/server.js",
@@ -26,11 +26,11 @@
26
26
  "@tinkoff/monkeypatch": "2.0.3",
27
27
  "@tinkoff/terminus": "0.1.5",
28
28
  "@tinkoff/url": "0.8.4",
29
- "@tramvai/module-cache-warmup": "2.39.2",
30
- "@tramvai/module-metrics": "2.39.2",
31
- "@tramvai/papi": "2.39.2",
32
- "@tramvai/tokens-server": "2.39.2",
33
- "@tramvai/tokens-server-private": "2.39.2",
29
+ "@tramvai/module-cache-warmup": "2.40.0",
30
+ "@tramvai/module-metrics": "2.40.0",
31
+ "@tramvai/papi": "2.40.0",
32
+ "@tramvai/tokens-server": "2.40.0",
33
+ "@tramvai/tokens-server-private": "2.40.0",
34
34
  "fastify": "^4.6.0",
35
35
  "fastify-plugin": "^4.2.1",
36
36
  "@fastify/cookie": "^8.1.0",
@@ -42,11 +42,11 @@
42
42
  "peerDependencies": {
43
43
  "@tinkoff/dippy": "0.8.9",
44
44
  "@tinkoff/utils": "^2.1.2",
45
- "@tramvai/cli": "2.39.2",
46
- "@tramvai/core": "2.39.2",
47
- "@tramvai/module-common": "2.39.2",
48
- "@tramvai/module-environment": "2.39.2",
49
- "@tramvai/tokens-common": "2.39.2",
45
+ "@tramvai/cli": "2.40.0",
46
+ "@tramvai/core": "2.40.0",
47
+ "@tramvai/module-common": "2.40.0",
48
+ "@tramvai/module-environment": "2.40.0",
49
+ "@tramvai/tokens-common": "2.40.0",
50
50
  "tslib": "^2.4.0"
51
51
  },
52
52
  "devDependencies": {