mirror of
https://github.com/Tzahi12345/YoutubeDL-Material.git
synced 2026-04-24 07:23:21 +03:00
Changed backend logging for server start to give more information (namely version)
This commit is contained in:
@@ -21,6 +21,7 @@ const url_api = require('url');
|
|||||||
var config_api = require('./config.js');
|
var config_api = require('./config.js');
|
||||||
var subscriptions_api = require('./subscriptions')
|
var subscriptions_api = require('./subscriptions')
|
||||||
const CONSTS = require('./consts')
|
const CONSTS = require('./consts')
|
||||||
|
const { spawn } = require('child_process')
|
||||||
|
|
||||||
var app = express();
|
var app = express();
|
||||||
|
|
||||||
@@ -126,29 +127,33 @@ async function startServer() {
|
|||||||
if (usingEncryption)
|
if (usingEncryption)
|
||||||
{
|
{
|
||||||
https.createServer(options, app).listen(backendPort, function() {
|
https.createServer(options, app).listen(backendPort, function() {
|
||||||
console.log('HTTPS: Started on PORT ' + backendPort);
|
console.log(`YoutubeDL-Material ${CONSTS['CURRENT_VERSION']} started on port ${backendPort} - using SSL`);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
app.listen(backendPort,function(){
|
app.listen(backendPort,function(){
|
||||||
console.log("HTTP: Started on PORT " + backendPort);
|
console.log(`YoutubeDL-Material ${CONSTS['CURRENT_VERSION']} started on PORT ${backendPort}`);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// getLatestVersion();
|
// getLatestVersion();
|
||||||
|
// restartServer();
|
||||||
updateServer();
|
updateServer();
|
||||||
}
|
}
|
||||||
|
|
||||||
async function restartServer() {
|
async function restartServer() {
|
||||||
console.log('Restarting server...');
|
|
||||||
const restartProcess = () => {
|
const restartProcess = () => {
|
||||||
spawn(process.argv[1], process.argv.slice(2), {
|
spawn('node', ['app.js'], {
|
||||||
detached: true,
|
detached: true,
|
||||||
stdio: ['ignore', out, err]
|
stdio: 'inherit'
|
||||||
}).unref()
|
}).unref()
|
||||||
process.exit()
|
process.exit()
|
||||||
}
|
}
|
||||||
|
console.log('Update complete! Restarting server...');
|
||||||
|
|
||||||
|
// the following line restarts the server through nodemon
|
||||||
|
fs.writeFileSync('restart.json', 'internal use only');
|
||||||
}
|
}
|
||||||
|
|
||||||
async function updateServer() {
|
async function updateServer() {
|
||||||
@@ -309,6 +314,12 @@ async function getLatestVersion() {
|
|||||||
fetch('https://api.github.com/repos/tzahi12345/youtubedl-material/releases/latest', {method: 'Get'})
|
fetch('https://api.github.com/repos/tzahi12345/youtubedl-material/releases/latest', {method: 'Get'})
|
||||||
.then(async res => res.json())
|
.then(async res => res.json())
|
||||||
.then(async (json) => {
|
.then(async (json) => {
|
||||||
|
if (json['message']) {
|
||||||
|
// means there's an error in getting latest version
|
||||||
|
console.log(`ERROR: Received the following message from GitHub's API:`);
|
||||||
|
console.log(json['message']);
|
||||||
|
if (json['documentation_url']) console.log(`Associated URL: ${json['documentation_url']}`)
|
||||||
|
}
|
||||||
resolve(json['tag_name']);
|
resolve(json['tag_name']);
|
||||||
return;
|
return;
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user