Update server
ci/woodpecker/push/woodpecker Pipeline was successful
Podrobnosti
ci/woodpecker/push/woodpecker Pipeline was successful
Podrobnosti
This commit is contained in:
rodič
d6284f8172
revize
a9990acca6
|
@ -4,19 +4,31 @@ const Hapi = require('@hapi/hapi');
|
|||
const fs = require('fs')
|
||||
const { execSync } = require('child_process')
|
||||
|
||||
const dir = '/corn/sftpgo/data/data/gweicz-sysinfo'
|
||||
const SPEC_FILE = `${dir}/spec/services.yaml`
|
||||
|
||||
let spec = null
|
||||
let mtime = null
|
||||
|
||||
async function buildSpec () {
|
||||
console.log('Building spec ..')
|
||||
const dir = '/corn/sftpgo/data/data/gweicz-sysinfo'
|
||||
|
||||
const out = execSync('cd .. && npm run build', { env: { GWEICZ_SYSINFO_SPEC: '/corn/sftpgo/data/data/gweicz-sysinfo/spec/services.yaml' }})
|
||||
const out = execSync('cd .. && npm run build', { env: { GWEICZ_SYSINFO_SPEC: SPEC_FILE }})
|
||||
console.log(out.toString())
|
||||
|
||||
console.log('Spec builded. Done.')
|
||||
mtime = new Date()
|
||||
spec = JSON.parse(fs.readFileSync('../build/spec.json'))
|
||||
}
|
||||
|
||||
async function checkLoaded () {
|
||||
const specStat = fs.statSync(SPEC_FILE)
|
||||
if (new Date(specStat.mtime) > mtime) {
|
||||
console.log('Found new version, rebuilding ..')
|
||||
await buildSpec()
|
||||
}
|
||||
}
|
||||
|
||||
const init = async () => {
|
||||
|
||||
const server = Hapi.server({
|
||||
|
@ -39,6 +51,10 @@ const init = async () => {
|
|||
await buildSpec()
|
||||
}, 1000 * 60 * 15)
|
||||
|
||||
setTimeout(async () => {
|
||||
await checkLoaded()
|
||||
}, 1000 * 60)
|
||||
|
||||
await buildSpec()
|
||||
};
|
||||
|
||||
|
|
Načítá se…
Odkázat v novém úkolu