Additional logging and auto restart every 6 hours
This commit is contained in:
parent
2926d0e468
commit
92aa257520
13
main.js
13
main.js
|
@ -7,8 +7,10 @@ const config = JSON.parse(fs.readFileSync("config.json"));
|
||||||
|
|
||||||
const updateInterval = 5000;
|
const updateInterval = 5000;
|
||||||
const retryInterval = 30000;
|
const retryInterval = 30000;
|
||||||
|
const maxUptime = 6 * 60 * 60 * 1000; // Maximum uptime before restart (6 hours)
|
||||||
|
|
||||||
let rp;
|
let rp;
|
||||||
|
let startTime = Date.now();
|
||||||
|
|
||||||
function formatNumber(number) {
|
function formatNumber(number) {
|
||||||
var x = number.split(".");
|
var x = number.split(".");
|
||||||
|
@ -68,7 +70,14 @@ async function updateStatus() {
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log("Discord status updated.");
|
console.log("Discord status updated. Current track: " + data.trackName + ", Artist: " + data.artist);
|
||||||
|
|
||||||
|
// check if uptime exceeds maximum uptime
|
||||||
|
if ((Date.now() - startTime) > maxUptime) {
|
||||||
|
console.log("Max uptime reached, restarting process...");
|
||||||
|
process.exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
setTimeout(updateStatus, updateInterval);
|
setTimeout(updateStatus, updateInterval);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Failed to update status:", error);
|
console.error("Failed to update status:", error);
|
||||||
|
@ -144,4 +153,4 @@ async function fetchCurrentScrobble(user) {
|
||||||
console.error("Failed to fetch current scrobble for track: " + lastTrackName + " by artist: " + lastArtist, error);
|
console.error("Failed to fetch current scrobble for track: " + lastTrackName + " by artist: " + lastArtist, error);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue