Spaces:
Running
Running
Commit
·
239231e
1
Parent(s):
f2e9e21
Add proxy render
Browse files- proxy-renderer.js +19 -3
proxy-renderer.js
CHANGED
|
@@ -10,7 +10,7 @@ const { GenerateScript } = await import('./src/GenerateScript.cjs');
|
|
| 10 |
|
| 11 |
const originalManuScriptPath = path.join(process.cwd(), 'public/original_manuscript.json');
|
| 12 |
let cmd = `npm run preview`;
|
| 13 |
-
|
| 14 |
export const renderProxy = async (outFile, options) => {
|
| 15 |
const ScriptStr = fs.readFileSync(originalManuScriptPath);
|
| 16 |
const ScriptInput = JSON.parse(ScriptStr);
|
|
@@ -77,14 +77,30 @@ export const renderProxy = async (outFile, options) => {
|
|
| 77 |
childProcess.stdout.on('data', (data) => {
|
| 78 |
console.log(data)
|
| 79 |
if (data.includes('Cleanup: Closing browser instance')) {
|
| 80 |
-
|
|
|
|
|
|
|
|
|
|
| 81 |
}
|
| 82 |
});
|
| 83 |
childProcess.stderr.on('data', (data) => {
|
| 84 |
console.error(data)
|
| 85 |
-
|
|
|
|
| 86 |
reject(data)
|
| 87 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 88 |
});
|
| 89 |
}).catch(reject)
|
| 90 |
})
|
|
|
|
| 10 |
|
| 11 |
const originalManuScriptPath = path.join(process.cwd(), 'public/original_manuscript.json');
|
| 12 |
let cmd = `npm run preview`;
|
| 13 |
+
var childProcess = exec(cmd);
|
| 14 |
export const renderProxy = async (outFile, options) => {
|
| 15 |
const ScriptStr = fs.readFileSync(originalManuScriptPath);
|
| 16 |
const ScriptInput = JSON.parse(ScriptStr);
|
|
|
|
| 77 |
childProcess.stdout.on('data', (data) => {
|
| 78 |
console.log(data)
|
| 79 |
if (data.includes('Cleanup: Closing browser instance')) {
|
| 80 |
+
try {
|
| 81 |
+
resolve(outFile)
|
| 82 |
+
}
|
| 83 |
+
catch (e) { }
|
| 84 |
}
|
| 85 |
});
|
| 86 |
childProcess.stderr.on('data', (data) => {
|
| 87 |
console.error(data)
|
| 88 |
+
try {
|
| 89 |
+
if (data.includes('Failed to render')) {
|
| 90 |
reject(data)
|
| 91 |
}
|
| 92 |
+
} catch (e) { }
|
| 93 |
+
|
| 94 |
+
});
|
| 95 |
+
childProcess.on('close', (code) => {
|
| 96 |
+
console.log('Render studio exited. Restarting...');
|
| 97 |
+
setTimeout(() => {
|
| 98 |
+
childProcess = exec(cmd);
|
| 99 |
+
}, 2000)
|
| 100 |
+
sendToObserver(jobId, code === 0 ? 'completed' : 'failed');
|
| 101 |
+
try {
|
| 102 |
+
reject(data)
|
| 103 |
+
} catch (e) { }
|
| 104 |
});
|
| 105 |
}).catch(reject)
|
| 106 |
})
|