@naturalcycles/backend-lib 4.19.2 → 4.20.1

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.
@@ -22,16 +22,22 @@ async function deployGae(opt = {}) {
22
22
  gaeService,
23
23
  gaeVersion,
24
24
  });
25
- try {
26
- // gcloud app deploy ./tmp/deploy/app.yaml --project $deployInfo_gaeProject --version $deployInfo_gaeVersion --quiet --no-promote
27
- (0, nodejs_lib_1.execVoidCommandSync)(`gcloud app deploy ${appYamlPath} --project ${gaeProject} --version ${gaeVersion} --quiet --no-promote`, [], { shell: true });
28
- }
29
- catch (err) {
30
- if (logOnFailure) {
31
- logs(gaeProject, gaeService, gaeVersion);
25
+ await (0, js_lib_1.pRetry)(async () => {
26
+ try {
27
+ (0, nodejs_lib_1.execVoidCommandSync)(`gcloud app deploy ${appYamlPath} --project ${gaeProject} --version ${gaeVersion} --quiet --no-promote`, [], { shell: true });
32
28
  }
33
- throw err;
34
- }
29
+ catch (err) {
30
+ if (logOnFailure) {
31
+ logs(gaeProject, gaeService, gaeVersion);
32
+ }
33
+ throw err;
34
+ }
35
+ }, {
36
+ name: 'deploy',
37
+ maxAttempts: 2,
38
+ delay: 30000,
39
+ predicate: err => (0, js_lib_1._anyToError)(err).message.includes('operation is already in progress'),
40
+ });
35
41
  // Health check (versionUrl)
36
42
  // yarn deploy-health-check --url $deployInfo_versionUrl --repeat 3 --timeoutSec 180 --intervalSec 2
37
43
  await (0, deployHealthCheck_1.deployHealthCheck)(versionUrl, opt);
@@ -52,7 +52,7 @@ const serverStatsHTMLHandler = (req, res) => {
52
52
  `<td align="right"><pre>${all5xx}</pre></td>`,
53
53
  ...percentiles.map(pc => `<td align="right"><pre>${Math.round((0, js_lib_1._percentile)(allLatencies, pc))}</pre></td>`),
54
54
  `</tr>`,
55
- ...(0, js_lib_1._sortBy)((0, js_lib_1._stringMapEntries)(serverStatsMap), ([_, stat]) => (0, js_lib_1._get)(stat, sortBy), false, !asc).map(([endpoint, stat]) => {
55
+ ...(0, js_lib_1._sortBy)((0, js_lib_1._stringMapEntries)(serverStatsMap), ([_, stat]) => (0, js_lib_1._get)(stat, sortBy), false, asc ? 'asc' : 'desc').map(([endpoint, stat]) => {
56
56
  return [
57
57
  '<tr>',
58
58
  `<td><pre>${endpoint}</pre></td>`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@naturalcycles/backend-lib",
3
- "version": "4.19.2",
3
+ "version": "4.20.1",
4
4
  "scripts": {
5
5
  "prepare": "husky install",
6
6
  "serve": "APP_ENV=dev nodemon",
@@ -1,5 +1,5 @@
1
1
  import { buildProdCommand } from '@naturalcycles/dev-lib'
2
- import { _objectAssign } from '@naturalcycles/js-lib'
2
+ import { _anyToError, _objectAssign, pRetry } from '@naturalcycles/js-lib'
3
3
  import { execVoidCommandSync } from '@naturalcycles/nodejs-lib'
4
4
  import { deployHealthCheck, DeployHealthCheckOptions } from './deployHealthCheck'
5
5
  import { deployPrepare, DeployPrepareOptions } from './deployPrepare'
@@ -29,20 +29,28 @@ export async function deployGae(opt: DeployGaeOptions = {}): Promise<void> {
29
29
  gaeVersion,
30
30
  })
31
31
 
32
- try {
33
- // gcloud app deploy ./tmp/deploy/app.yaml --project $deployInfo_gaeProject --version $deployInfo_gaeVersion --quiet --no-promote
34
- execVoidCommandSync(
35
- `gcloud app deploy ${appYamlPath} --project ${gaeProject} --version ${gaeVersion} --quiet --no-promote`,
36
- [],
37
- { shell: true },
38
- )
39
- } catch (err) {
40
- if (logOnFailure) {
41
- logs(gaeProject, gaeService, gaeVersion)
42
- }
43
-
44
- throw err
45
- }
32
+ await pRetry(
33
+ async () => {
34
+ try {
35
+ execVoidCommandSync(
36
+ `gcloud app deploy ${appYamlPath} --project ${gaeProject} --version ${gaeVersion} --quiet --no-promote`,
37
+ [],
38
+ { shell: true },
39
+ )
40
+ } catch (err) {
41
+ if (logOnFailure) {
42
+ logs(gaeProject, gaeService, gaeVersion)
43
+ }
44
+ throw err
45
+ }
46
+ },
47
+ {
48
+ name: 'deploy',
49
+ maxAttempts: 2,
50
+ delay: 30_000,
51
+ predicate: err => _anyToError(err).message.includes('operation is already in progress'),
52
+ },
53
+ )
46
54
 
47
55
  // Health check (versionUrl)
48
56
  // yarn deploy-health-check --url $deployInfo_versionUrl --repeat 3 --timeoutSec 180 --intervalSec 2
@@ -88,7 +88,7 @@ export const serverStatsHTMLHandler: BackendRequestHandler = (req, res) => {
88
88
  _stringMapEntries(serverStatsMap),
89
89
  ([_, stat]) => _get(stat, sortBy),
90
90
  false,
91
- !asc,
91
+ asc ? 'asc' : 'desc',
92
92
  ).map(([endpoint, stat]) => {
93
93
  return [
94
94
  '<tr>',