@xen-orchestra/backups 0.46.1 → 0.47.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/_backupWorker.mjs +26 -1
- package/package.json +3 -1
package/_backupWorker.mjs
CHANGED
|
@@ -2,7 +2,10 @@ import { createLogger } from '@xen-orchestra/log'
|
|
|
2
2
|
import { catchGlobalErrors } from '@xen-orchestra/log/configure'
|
|
3
3
|
|
|
4
4
|
import Disposable from 'promise-toolbox/Disposable'
|
|
5
|
+
import humanFormat from 'human-format'
|
|
5
6
|
import ignoreErrors from 'promise-toolbox/ignoreErrors'
|
|
7
|
+
import mapValues from 'lodash/mapValues.js'
|
|
8
|
+
import ms from 'ms'
|
|
6
9
|
import { compose } from '@vates/compose'
|
|
7
10
|
import { createCachedLookup } from '@vates/cached-dns.lookup'
|
|
8
11
|
import { createDebounceResource } from '@vates/disposable/debounceResource.js'
|
|
@@ -20,7 +23,7 @@ createCachedLookup().patchGlobal()
|
|
|
20
23
|
|
|
21
24
|
const logger = createLogger('xo:backups:worker')
|
|
22
25
|
catchGlobalErrors(logger)
|
|
23
|
-
const { debug } = logger
|
|
26
|
+
const { debug, info } = logger
|
|
24
27
|
|
|
25
28
|
class BackupWorker {
|
|
26
29
|
#config
|
|
@@ -149,6 +152,27 @@ process.on('message', async message => {
|
|
|
149
152
|
debug('message received', { message })
|
|
150
153
|
|
|
151
154
|
if (message.action === 'run') {
|
|
155
|
+
const resourceStart = process.resourceUsage()
|
|
156
|
+
const timeStart = process.hrtime.bigint()
|
|
157
|
+
info('starting backup')
|
|
158
|
+
|
|
159
|
+
process.on('exit', exitCode => {
|
|
160
|
+
const resourceUsage = mapValues(process.resourceUsage(), (end, key) => end - resourceStart[key])
|
|
161
|
+
const cpuTotal = resourceUsage.userCPUTime + resourceUsage.systemCPUTime
|
|
162
|
+
const duration = Number((process.hrtime.bigint() - timeStart) / 1000n) // in μs
|
|
163
|
+
|
|
164
|
+
info('process will exit', {
|
|
165
|
+
duration,
|
|
166
|
+
exitCode,
|
|
167
|
+
resourceUsage,
|
|
168
|
+
summary: {
|
|
169
|
+
duration: ms(duration / 1000),
|
|
170
|
+
cpuUsage: Math.round((100 * cpuTotal) / duration) + '%',
|
|
171
|
+
memoryUsage: humanFormat.bytes(resourceUsage.maxRSS * 1024),
|
|
172
|
+
},
|
|
173
|
+
})
|
|
174
|
+
})
|
|
175
|
+
|
|
152
176
|
const backupWorker = new BackupWorker(message.data)
|
|
153
177
|
try {
|
|
154
178
|
const result = message.runWithLogs
|
|
@@ -177,6 +201,7 @@ process.on('message', async message => {
|
|
|
177
201
|
status: 'failure',
|
|
178
202
|
})
|
|
179
203
|
} finally {
|
|
204
|
+
info('backup has ended')
|
|
180
205
|
await ignoreErrors.call(backupWorker.debounceResource.flushAll())
|
|
181
206
|
process.disconnect()
|
|
182
207
|
}
|
package/package.json
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"type": "git",
|
|
9
9
|
"url": "https://github.com/vatesfr/xen-orchestra.git"
|
|
10
10
|
},
|
|
11
|
-
"version": "0.
|
|
11
|
+
"version": "0.47.0",
|
|
12
12
|
"engines": {
|
|
13
13
|
"node": ">=14.18"
|
|
14
14
|
},
|
|
@@ -36,8 +36,10 @@
|
|
|
36
36
|
"d3-time-format": "^4.1.0",
|
|
37
37
|
"decorator-synchronized": "^0.6.0",
|
|
38
38
|
"golike-defer": "^0.5.1",
|
|
39
|
+
"human-format": "^1.2.0",
|
|
39
40
|
"limit-concurrency-decorator": "^0.5.0",
|
|
40
41
|
"lodash": "^4.17.20",
|
|
42
|
+
"ms": "^2.1.3",
|
|
41
43
|
"node-zone": "^0.4.0",
|
|
42
44
|
"parse-pairs": "^2.0.0",
|
|
43
45
|
"promise-toolbox": "^0.21.0",
|