service-core/test/runner_cluster.mjs
Jonatan Nilsson 618cfd0451
All checks were successful
continuous-integration/appveyor/branch AppVeyor build succeeded
log: Workers in cluster will now properly notify master of newlog entries. Useful for sc-manager
2022-04-01 09:59:47 +00:00

49 lines
1.2 KiB
JavaScript

import fs from 'fs'
import cluster from 'cluster'
import { runner } from '../core/runner.mjs'
if (cluster.isPrimary) {
try {
fs.rmSync(util.getPathFromRoot('./db.json'))
} catch {}
}
runner(import.meta.url, {
name: 'test-runner-cluster',
testappcluster: {
cluster: 2,
port: 31313,
provider: 'git',
url: 'http://localhost:61412/releases',
updateEvery: 0.014,
heartbeatTimeout: 100,
heartbeatAttempts: 3,
heartbeatAttemptsWait: 100,
log: [{
stream: 'process.stdout',
level: 'info',
}],
}
}, 'db.json')
.then(
function(core) {
if (cluster.isPrimary) {
let app = core.applications[0]
app.ctx.log.on('newlog', function(record) {
if (record.name !== app.name) {
console.log(`[FROMWORKERAPP] ${record.name} (${record.pid}) ${record.msg}`)
}
})
core.log.on('newlog', function(record) {
if (record.pid !== process.pid) {
console.log(`[FROMWORKERCORE] ${record.name} (${record.pid}) ${record.msg}`)
}
})
}
core.log.info('core is running')
},
function(err) {
runner.log.error(err, 'Error starting runner')
process.exit(1)
}
)