Import/calculations improvements
This commit is contained in:
@@ -1,6 +1,12 @@
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const { spawn } = require('child_process');
|
||||
|
||||
// Maintenance switch: `touch .pause-auto-update` in inventory-server/ to make the
|
||||
// recurring full-update a no-op (e.g. during a long manual full re-import or a
|
||||
// snapshot rebuild). Remove the file to resume.
|
||||
const PAUSE_FILE = path.join(__dirname, '..', '.pause-auto-update');
|
||||
|
||||
function outputProgress(data) {
|
||||
if (!data.status) {
|
||||
data = {
|
||||
@@ -22,12 +28,8 @@ function runScript(scriptPath) {
|
||||
child.stdout.on('data', (data) => {
|
||||
const lines = data.toString().split('\n');
|
||||
lines.filter(line => line.trim()).forEach(line => {
|
||||
try {
|
||||
console.log(line); // Pass through the JSON output
|
||||
output += line + '\n';
|
||||
} catch (e) {
|
||||
console.log(line); // If not JSON, just log it directly
|
||||
}
|
||||
console.log(line); // Pass through the (usually JSON) output
|
||||
output += line + '\n';
|
||||
});
|
||||
});
|
||||
|
||||
@@ -50,6 +52,14 @@ function runScript(scriptPath) {
|
||||
}
|
||||
|
||||
async function fullUpdate() {
|
||||
if (fs.existsSync(PAUSE_FILE)) {
|
||||
outputProgress({
|
||||
status: 'complete',
|
||||
operation: 'Full update skipped',
|
||||
message: `Auto-update is paused (${PAUSE_FILE} exists) — remove the file to resume`
|
||||
});
|
||||
return;
|
||||
}
|
||||
try {
|
||||
// Step 1: Import from Production
|
||||
outputProgress({
|
||||
|
||||
Reference in New Issue
Block a user