Skip to content

Commit

Permalink
fix: add backend logging
Browse files Browse the repository at this point in the history
  • Loading branch information
angrybayblade committed Mar 13, 2024
1 parent 4d0528e commit 04c8ab4
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion electron/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const {
} = require('electron');
const { spawn, exec } = require('child_process');
const path = require('path');
const url = require('url');
const fs = require('fs');
const os = require('os');
const next = require('next');
const http = require('http');
Expand Down Expand Up @@ -168,6 +168,10 @@ const createMainWindow = () => {
};

async function launchDaemon() {
function appendLog(data) {
fs.appendFileSync(`${OperateDirectory}/logs.txt`, data.trim() + "\n", { "encoding": "utf-8" })
return data
}
const check = new Promise(function (resolve, reject) {
operateDaemon = spawn(OperateCmd, [
'daemon',
Expand All @@ -184,6 +188,10 @@ async function launchDaemon() {
) {
resolve({ running: false, error: 'Port already in use' });
}
console.log(appendLog(data.toString().trim()));
});
operateDaemon.stdout.on('data', (data) => {
console.log(appendLog(data.toString().trim()));
});
});
return await check;
Expand Down

0 comments on commit 04c8ab4

Please sign in to comment.