@naturalcycles/backend-lib
Advanced tools
Comparing version 1.11.1 to 1.12.0
@@ -0,1 +1,8 @@ | ||
# [1.12.0](https://github.com/NaturalCycles/backend-lib/compare/v1.11.1...v1.12.0) (2019-07-16) | ||
### Features | ||
* yarn deploy-gae ([18b92fc](https://github.com/NaturalCycles/backend-lib/commit/18b92fc)) | ||
## [1.11.1](https://github.com/NaturalCycles/backend-lib/compare/v1.11.0...v1.11.1) (2019-07-16) | ||
@@ -2,0 +9,0 @@ |
@@ -13,46 +13,5 @@ #!/usr/bin/env node | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const js_lib_1 = require("@naturalcycles/js-lib"); | ||
const promise_lib_1 = require("@naturalcycles/promise-lib"); | ||
const time_lib_1 = require("@naturalcycles/time-lib"); | ||
const got = require("got"); | ||
require("loud-rejection/register"); | ||
const yargs = require("yargs"); | ||
void main(); | ||
async function main() { | ||
const { url, repeat, timeoutSec, intervalSec } = yargs.options({ | ||
url: { | ||
type: 'string', | ||
demandOption: true, | ||
}, | ||
repeat: { | ||
type: 'number', | ||
default: 3, | ||
}, | ||
timeoutSec: { | ||
type: 'number', | ||
default: 30, | ||
}, | ||
intervalSec: { | ||
type: 'number', | ||
default: 2, | ||
}, | ||
}).argv; | ||
for await (const attempt of js_lib_1._range(1, repeat + 1)) { | ||
console.log(`>> ${url} (attempt ${attempt} / ${repeat})`); | ||
const started = Date.now(); | ||
const { statusCode } = await got(url, { | ||
json: true, | ||
timeout: timeoutSec * 1000, | ||
retry: 0, | ||
followRedirect: false, | ||
throwHttpErrors: false, | ||
}); | ||
console.log(`<< HTTP ${statusCode} in ${time_lib_1.since(started)}`); | ||
if (statusCode !== 200) { | ||
console.log(`Health check failed!`); | ||
process.exit(1); | ||
} | ||
await promise_lib_1.pDelay(intervalSec * 1000); | ||
} | ||
} | ||
const deployHealthCheck_command_1 = require("../gae/deployHealthCheck.command"); | ||
void deployHealthCheck_command_1.deployHealthCheckCommand(); | ||
//# sourceMappingURL=deploy-health-check.js.map |
{ | ||
"name": "@naturalcycles/backend-lib", | ||
"version": "1.11.1", | ||
"version": "1.12.0", | ||
"scripts": { | ||
"deploy-gae": "yarn tsn ./src/bin/deploy-gae.ts", | ||
"deploy-prepare": "yarn tsn ./src/bin/deploy-prepare.ts", | ||
@@ -56,2 +57,3 @@ "deploy-prepare-debug": "yarn tsn ./src/bin/deploy-prepare.ts --projectDir ./src/test/project", | ||
"bin": { | ||
"deploy-gae": "dist/bin/deploy-gae.js", | ||
"deploy-prepare": "dist/bin/deploy-prepare.js", | ||
@@ -58,0 +60,0 @@ "deploy-health-check": "dist/bin/deploy-health-check.js" |
@@ -13,52 +13,5 @@ #!/usr/bin/env node | ||
import { _range } from '@naturalcycles/js-lib' | ||
import { pDelay } from '@naturalcycles/promise-lib' | ||
import { since } from '@naturalcycles/time-lib' | ||
import * as got from 'got' | ||
import 'loud-rejection/register' | ||
import * as yargs from 'yargs' | ||
import { deployHealthCheckCommand } from '../gae/deployHealthCheck.command' | ||
void main() | ||
async function main () { | ||
const { url, repeat, timeoutSec, intervalSec } = yargs.options({ | ||
url: { | ||
type: 'string', | ||
demandOption: true, | ||
}, | ||
repeat: { | ||
type: 'number', | ||
default: 3, | ||
}, | ||
timeoutSec: { | ||
type: 'number', | ||
default: 30, | ||
}, | ||
intervalSec: { | ||
type: 'number', | ||
default: 2, | ||
}, | ||
}).argv | ||
for await (const attempt of _range(1, repeat + 1)) { | ||
console.log(`>> ${url} (attempt ${attempt} / ${repeat})`) | ||
const started = Date.now() | ||
const { statusCode } = await got(url, { | ||
json: true, | ||
timeout: timeoutSec * 1000, | ||
retry: 0, // no retries allowed | ||
followRedirect: false, | ||
throwHttpErrors: false, | ||
}) | ||
console.log(`<< HTTP ${statusCode} in ${since(started)}`) | ||
if (statusCode !== 200) { | ||
console.log(`Health check failed!`) | ||
process.exit(1) | ||
} | ||
await pDelay(intervalSec * 1000) | ||
} | ||
} | ||
void deployHealthCheckCommand() |
Sorry, the diff of this file is not supported yet
98657
113
1960
8