@rhizogrip/spore-cli 1.50.0 → 1.52.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 +2 -2
- package/src/doctor.js +2 -0
- package/src/services.js +15 -11
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rhizogrip/spore-cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.52.0",
|
|
4
4
|
"author": {
|
|
5
5
|
"name": "Christophe Le Bars",
|
|
6
6
|
"email": "clb@toort.net"
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"minimist": "^1.2.8"
|
|
55
55
|
},
|
|
56
56
|
"optionalDependencies": {
|
|
57
|
-
"@rhizogrip/spore": "1.
|
|
57
|
+
"@rhizogrip/spore": "1.52.0"
|
|
58
58
|
},
|
|
59
59
|
"license": "Apache-2.0"
|
|
60
60
|
}
|
package/src/doctor.js
CHANGED
|
@@ -39,6 +39,8 @@ function serviceFindings (services, needsTick, replies) {
|
|
|
39
39
|
if (row.outdated) problem(row.name, `runs ${row.outdated.from} ${row.outdated.running}, and ${row.outdated.installed} is installed`, `spore service restart ${row.name}`)
|
|
40
40
|
if (row.enabled && row.active !== 'active') problem(row.name, `is enabled and ${row.active} (${row.sub})`, `spore service log ${row.name}`)
|
|
41
41
|
if (row.restarts) note(row.name, `systemd has restarted it ${row.restarts} time${row.restarts > 1 ? 's' : ''}`, `spore service log ${row.name}`)
|
|
42
|
+
const checked = services.check(row.name)
|
|
43
|
+
if (checked && !checked.ok) problem(row.name, `does not pass its check: ${checked.detail}`, `spore service show ${row.name}`)
|
|
42
44
|
}
|
|
43
45
|
const tick = listed.services.find(row => row.name === 'tick')
|
|
44
46
|
if (needsTick.length && !(tick.defined && tick.active === 'active')) {
|
package/src/services.js
CHANGED
|
@@ -438,21 +438,25 @@ export function createServices ({ roots = pluginRoots() } = {}) {
|
|
|
438
438
|
return { ...shown, units, log }
|
|
439
439
|
},
|
|
440
440
|
|
|
441
|
+
/**
|
|
442
|
+
* What the service's `check` says now, as `define` runs it: `{ ok, detail }`, `detail` what it
|
|
443
|
+
* wrote on stderr, or else on stdout; null for a service that declares none.
|
|
444
|
+
*/
|
|
445
|
+
check (name) {
|
|
446
|
+
const { service, instance } = parse(name, { verb: 'show' })
|
|
447
|
+
if (!service.check) return null
|
|
448
|
+
const [command, args] = service.check({ ...INSTALL, instance })
|
|
449
|
+
const checked = systemRun(command, args)
|
|
450
|
+
return { ok: checked.status === 0, detail: (checked.stderr || checked.stdout || '').trim() || `exit ${checked.status}` }
|
|
451
|
+
},
|
|
452
|
+
|
|
441
453
|
define (name) {
|
|
442
454
|
const one = parse(name, { verb: 'define' })
|
|
443
|
-
const { service
|
|
455
|
+
const { service } = one
|
|
444
456
|
requireSystemd()
|
|
445
457
|
refuseForeign(one, name)
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
const checked = systemRun(command, args)
|
|
449
|
-
if (checked.status !== 0) {
|
|
450
|
-
throw new SporeError(`${name} would not start`, {
|
|
451
|
-
type: 'SERVICE_NOT_READY',
|
|
452
|
-
detail: (checked.stderr || checked.stdout || '').trim() || `exit ${checked.status}`
|
|
453
|
-
})
|
|
454
|
-
}
|
|
455
|
-
}
|
|
458
|
+
const checked = this.check(name)
|
|
459
|
+
if (checked && !checked.ok) throw new SporeError(`${name} did not pass its check`, { type: 'SERVICE_NOT_READY', detail: checked.detail })
|
|
456
460
|
mkdirSync(UNIT_DIR, { recursive: true })
|
|
457
461
|
const units = []
|
|
458
462
|
for (const [file, text] of Object.entries(renderUnits(one.base, { roots }))) {
|