@rpcbase/cli 0.190.0 → 0.192.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/package.json +1 -1
- package/src/cmd-deploy/index.js +11 -4
- package/src/cmd-ssh.js +9 -3
package/package.json
CHANGED
package/src/cmd-deploy/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { execSync } from "child_process"
|
|
1
|
+
import { execFileSync, execSync } from "child_process"
|
|
2
2
|
import fs from "fs"
|
|
3
3
|
import os from "os"
|
|
4
4
|
import path from "path"
|
|
@@ -246,9 +246,15 @@ export const deploy = async (argv) => {
|
|
|
246
246
|
let preparedDeploy = null
|
|
247
247
|
|
|
248
248
|
const ssh = async (command, stdioInherit = false) => {
|
|
249
|
-
const sshCommand = `ssh -i "${keyPath}" -o StrictHostKeyChecking=no ${user}@${host} "${command}"`
|
|
250
249
|
log(`${command}`)
|
|
251
|
-
const out =
|
|
250
|
+
const out = execFileSync("ssh", [
|
|
251
|
+
"-i",
|
|
252
|
+
keyPath,
|
|
253
|
+
"-o",
|
|
254
|
+
"StrictHostKeyChecking=no",
|
|
255
|
+
`${user}@${host}`,
|
|
256
|
+
command,
|
|
257
|
+
], {
|
|
252
258
|
stdio: (argv.verbose || stdioInherit) ? "inherit" : "pipe",
|
|
253
259
|
})
|
|
254
260
|
const res = out?.toString()?.trim() || ""
|
|
@@ -283,9 +289,10 @@ export const deploy = async (argv) => {
|
|
|
283
289
|
if (!Number.isFinite(port) || port <= 0) throw new Error(`Cannot healthcheck instance ${instance}: invalid port`)
|
|
284
290
|
|
|
285
291
|
const url = `http://127.0.0.1:${port}/`
|
|
292
|
+
const healthcheckScript = `fetch(${JSON.stringify(url)}).then((res) => process.exit(res.status < 500 ? 0 : 1)).catch(() => process.exit(1))`
|
|
286
293
|
for (let attempt = 1; attempt <= 60; attempt += 1) {
|
|
287
294
|
try {
|
|
288
|
-
await ssh(`node -e
|
|
295
|
+
await ssh(`node -e ${shellQuote(healthcheckScript)}`)
|
|
289
296
|
console.log(`Instance ${instance} is healthy at ${url}`)
|
|
290
297
|
return
|
|
291
298
|
} catch {
|
package/src/cmd-ssh.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { execFileSync } from "child_process"
|
|
2
2
|
import fs from "fs"
|
|
3
3
|
import path from "path"
|
|
4
4
|
import os from "os"
|
|
@@ -45,9 +45,15 @@ export const ssh = async (argv) => {
|
|
|
45
45
|
let tempKeyPath = null
|
|
46
46
|
|
|
47
47
|
const execSsh = async (command, stdioInherit = true) => {
|
|
48
|
-
const sshCommand = `ssh -i "${keyPath}" -o StrictHostKeyChecking=no ${user}@${host} "${command}"`
|
|
49
48
|
log(`${command}`)
|
|
50
|
-
const out =
|
|
49
|
+
const out = execFileSync("ssh", [
|
|
50
|
+
"-i",
|
|
51
|
+
keyPath,
|
|
52
|
+
"-o",
|
|
53
|
+
"StrictHostKeyChecking=no",
|
|
54
|
+
`${user}@${host}`,
|
|
55
|
+
command,
|
|
56
|
+
], {
|
|
51
57
|
stdio: (argv.verbose || stdioInherit) ? "inherit" : "pipe",
|
|
52
58
|
})
|
|
53
59
|
const res = out?.toString()?.trim() || ""
|