cmangos / issues

This repository is used as a centralized point for all issues regarding CMaNGOS.
180 stars 47 forks source link

server restart on time🚀 [Feature Request] #3263

Open rmzV opened 1 year ago

rmzV commented 1 year ago

Feature Details

When you have your server at "long run" memory usage become abnormal (from 1.2 gb on start to 9gb from my experience).

is it possible to add blizzlike option "restart server at day/time"

Visualizations

No response

Benefits and Purpose

cleaning garbage data, less server load, become more "blizz like"

Core Versions

kelbren commented 1 year ago

With remote console enabled in cmangos there is a way to do this via telnet. If you are running linux this is fairly easy to do, I use a small bash script and place an entry in the crontab to run it on a schedule. It does requires installing "expect" from your distro. The crontab entry would be to the full path of the bash script with username and password as parameters, so the example here would be restart at 2am Tuesdays.

crontab entry

0 2 * * 2 /home/mangos/wrestart.sh username password

wrestart.sh

#!/usr/bin/expect
#
# uses 2 command line arguments username and password
#
set timeout 5
set userName [lindex $argv 0]
set password [lindex $argv 1]
spawn telnet 127.0.0.1 3443
# login info
expect "Username:"
send "$userName\r"
expect "Password:"
send "$password\r"
expect ">"
# change to the command you wish to execute.
send "server restart 60\r" 
expect "mangos>"
send "quit\r"
interact

I am sure there is a way to use scheduled tasks in windows to do something similar, I just don't have any examples atm.

insunaa commented 1 year ago

You can also run cmangos as a systemd service and use a systemd timer to restart it regularly https://github.com/cmangos/issues/wiki/Creating-a-systemd-service

rmzV commented 1 year ago

i am on windows. and trying to use "Task Scheduler" i created two schedules: 1) close mangos with action: taskkill /f /im "mangosd.exe"

with working perfectly fine and 2) restart app with action: E:\server\mangosd.exe

made this with this tutorial https://www.wintips.org/how-to-start-a-program-at-startup-with-task-scheduler/

this action doesnot work.