From 785306c59a8211b83a12b07f141a175e4d85dea8 Mon Sep 17 00:00:00 2001 From: Isaac Grynsztein Date: Mon, 30 Mar 2020 23:20:52 -0400 Subject: [PATCH] Added debug statements --- backend/app.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/backend/app.js b/backend/app.js index 607e97c..7b273da 100644 --- a/backend/app.js +++ b/backend/app.js @@ -137,10 +137,11 @@ async function startServer() { } // getLatestVersion(); - // updateServer(); + updateServer(); } async function restartServer() { + console.log('Restarting server...'); const restartProcess = () => { spawn(process.argv[1], process.argv.slice(2), { detached: true, @@ -166,12 +167,15 @@ async function updateServer() { // grab new package.json and public folder await downloadUpdateFiles(); + + restartServer(); }); } async function downloadUpdateFiles() { let tag = await getLatestVersion(); return new Promise(async resolve => { + console.log('Downloading new files...') var options = { owner: 'tzahi12345', repo: 'YoutubeDL-Material', @@ -185,6 +189,8 @@ async function downloadUpdateFiles() { fs.removeSync(path.join(__dirname, 'public')); fs.mkdirSync(path.join(__dirname, 'public')); + console.log(`Installing update ${tag}...`) + // downloads new package.json and adds new public dir files from the downloaded zip fs.createReadStream(path.join(__dirname, 'youtubedl-material-latest-release.zip')).pipe(unzipper.Parse()) .on('entry', function (entry) { @@ -206,6 +212,9 @@ async function downloadUpdateFiles() { } else { entry.autodrain(); } + }) + .on('close', function () { + resolve(true); }); }); }