ForgeEssentials

ForgeEssentials

339k Downloads

[1.12.2] [FEATURE]

bluetank10 opened this issue · 6 comments

commented

I have been search furiously for a solution to restart my server on a daily basis, I've already made it to restart on crash, but cannot schedule it for the life of me. However "all credit to 'Sashirō" we have created a script that will do exactly that. Helping remove memory leaks, and start the server fresh every x hours.

This is gonna be a long explanation but this is a feature in and of itself. First off 'Sashirō created a script that will stop the server, giving warnings at 5mins, 1 mins, and second intervals. This is the script.

`
//
// .js Restart Script
// Credit goes to 'Sashirō he created this

//
//
//
setInterval(function() {
Server.chatConfirm('Server is going to restart in five minutes!');

setTimeout(function() {
    Server.chatConfirm('Server is going to restart in one minute!');

    setTimeout(function() {
            restart_in_1_minutes(args);
    }, 60000); // one minute

}, 300000); // 5 minutes

}, 60000000); // Time when it should restart

function restart_in_1_minutes(args) {
//restart message
Server.chat('§e RESTARTING!');
//restart code
var hiddenChatSender = sender.doAs(null, true);
Server.runCommand(hiddenChatSender, 'stop');
}

`

After the server stops, some very simple code in the .batch file will simply restart it again. Just add the following lines.

@echo OFF
:start

"C:\Users\blank\OneDrive\Desktop\64-java for MC\bin\java.exe" -d64 -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -Dio.netty.leakDetection.level=advanced -XX:+CMSIncrementalPacing -XX:ParallelGCThreads=4 -XX:+AggressiveOpts -server -Xms4G -Xmx8G -jar forge-1.12.2-14.23.5.2847-universal.jar nogui

echo -----------------------

echo Press control+C to exit the server!

timeout 10

echo (%time%) Restarting!

goto start

PAUSE

This will promptly restart the server, and give you the option of ctrl + c to quit it entirely. I think this would be a great addition if there was a guide created for it. Most of all the work is complete just needs some more attention :)

Describe alternatives you've considered
GitHub script + concise explanation how to implement.

commented

figured it out

commented

K IDK why the formatting is soo odd. Can't figure that one out XD

commented

I created that script. Proof: 9df7791?diff=unified

And reading through this issue, I find nothing new for a request nor a bug thus closing

commented

Your cron.ts is great but It doesn’t work lol. Needs to be .js

commented

Also there is a new rule that includes you mayst have both.