Skip to content

Commit

Permalink
jlkjlj
Browse files Browse the repository at this point in the history
  • Loading branch information
chourmovs committed Sep 5, 2024
1 parent 9518713 commit abf2cd6
Showing 1 changed file with 32 additions and 19 deletions.
51 changes: 32 additions & 19 deletions webapp/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,29 +80,42 @@ app.get('/mpc-update', async (req, res) => {
// Start analysis (assuming blissify is command)
app.get('/start-analysis', async (req, res) => {
try {
const analysisProcess = spawn('blissify', ['start']);
let output = '';

analysisProcess.stdout.on('data', (data) => {
const analysisProcess = spawn('blissify', ['init', '/mnt/Musique']);
let output = '';
analysisProcess.stdout.on('data', (data) => {
output += data.toString();
console.log(`Analysis stdout: ${data}`);
});

analysisProcess.stderr.on('data', (data) => {
output += data.toString();
console.error(`Analysis stderr: ${data}`);
console.log(`Analysis stdout: ${data}`);
});

analysisProcess.stderr.on('data', (data) => {
output += data.toString();
console.error(`Analysis stderr: ${data}`);
});

const exitPromise = new Promise((resolve, reject) => {
analysisProcess.on('close', (code) => {
if (code === 0) {
resolve();
} else {
reject(new Error(`Analysis process exited with code ${code}`));
}
});

await new Promise((resolve) => {
analysisProcess.on('close', resolve);
analysisProcess.on('error', (err) => {
reject(err);
});

res.send(`Analysis started successfully: ${output}`);
} catch (error) {
console.error('Analysis start command failed:', error);
res.status(500).send('Error starting analysis');
}
});
});

await exitPromise;

res.send(`Analysis started successfully: ${output}`);
} catch (error) {
console.error('Analysis start command failed:', error);
res.status(500).send('Error starting analysis');
}
});

// Blissify update
app.get('/blissify-update', async (req, res) => {
Expand Down

0 comments on commit abf2cd6

Please sign in to comment.