fix python stdout and stderr integration
This commit is contained in:
1 parent
c8edb1da45
commit
d6ef6ea1dc
2 files changed
+4
-5
No files matched your search
@@ -76,10 +76,11 @@ export default class AiPythonConnector {
|
||||
const port = await this.port();
|
||||
return await new Promise((resolve, reject) => {
|
||||
console.log('ai: starting python backend');
|
||||
this.process = exec('. ../.venv/bin/activate && cd ../ai && python3 main.py --port ' + port);
|
||||
this.process = exec('. ../.venv/bin/activate && cd ../ai && python3 main.py --port ' + port,
|
||||
{env: {'PYTHONUNBUFFERED': '1'}});
|
||||
|
||||
this.process.stdout!.on('data', (data) => {
|
||||
console.log('ai: ' + data.toString());
|
||||
console.log('ai: ' + data.toString().replace(/\r?\n$/, ''));
|
||||
if (data.includes('' + port)) {
|
||||
console.log('ai: python backend started');
|
||||
resolve();
|
||||
@@ -87,7 +88,7 @@ export default class AiPythonConnector {
|
||||
});
|
||||
|
||||
this.process.stderr!.on('data', (data) => {
|
||||
console.error('ai: ' + data.toString());
|
||||
console.error('ai: ' + data.toString().replace(/\r?\n$/, ''));
|
||||
});
|
||||
|
||||
this.process.on('exit', (code) => {
|
||||
|
||||
Reference in new issue
Block a user