[DiscordArchive] So finally, it's only about adding the `after` line to my regular services in `systemd` ?
[DiscordArchive] So finally, it's only about adding the `after` line to my regular services in `systemd` ?
Archived author: Revision • Posted: 2022-05-17T16:51:41.399000+00:00
Original source
My crontab that runs every sunday, I use two different lines of course.
```
0 5 * * 0 screen -S world -p 0 -X stuff "server shutdown 3600^m" >/dev/null 2>&1
5 6 * * 0 cd /root && ./azerothcore.sh both all >/dev/null 2>&1
```
It'll send "server shutdown 3600" to the console at 5 AM and at 6:05 AM it'll run my stop/update/start script.
Archived author: Ruderalis • Posted: 2022-05-17T17:28:25.776000+00:00
Original source
Here is the stop script I just made :
`#!/bin/bash
LOG_FILE="/home/northrend/TheLegendaryKingdom/tlk-server.log"
WORLDSERVER_SHUTDOWN_DELAY=0
### Paramétrage du délai
if [[ $1 > 0 ]]; then
WORLDSERVER_SHUTDOWN_DELAY=$1
fi
### Arrêt du serveur (world)
echo "`date` LoA > Shutting down worldserver..." | tee -a $LOG_FILE
su northrend -c "/usr/bin/screen -S loa-world -X stuff \"server shutdown $WORLDSERVER_SHUTDOWN_DELAY\\r\""
su northrend -c "screen -x loa-world"
echo "`date` LoA > Done." | tee -a $LOG_FILE
### Arrêt des services
echo "`date` LoA > Stopping world service..." | tee -a $LOG_FILE
systemctl stop loa-auth loa-world | tee -a $LOG_FILE
echo "`date` TLK > Switch > Done." | tee -a $LOG_FILE`
Archived author: Revision • Posted: 2022-05-17T17:45:04.978000+00:00
Original source
The script will kill the server instantly
Archived author: Revision • Posted: 2022-05-17T17:45:13.585000+00:00
Original source
It doesn't stop and wait for the countdown to end
Archived author: Revision • Posted: 2022-05-17T17:47:59.280000+00:00
Original source
I just realized you're using `-x` and not `-X`, but I'm not sure why you're attaching to the screen at all.
Archived author: Ruderalis • Posted: 2022-05-17T17:54:21.332000+00:00
Original source
I attached to the screen because while it's attached, it does not continue proceeding the script. It will only continue when it leaves the screen, so when the worldserver is shutdown
Archived author: Ruderalis • Posted: 2022-05-17T17:54:57.137000+00:00
Original source
But I already rewrote it a bit, this was only to watch it and be sure to handle the delay correctly
Archived author: Ruderalis • Posted: 2022-05-17T17:55:17.483000+00:00
Original source
`#!/bin/bash
LOG_FILE="/home/northrend/TheLegendaryKingdom/tlk-server.log"
WORLDSERVER_SHUTDOWN_DELAY=0
### Paramétrage du délai
if [[ $1 > 0 ]]; then
WORLDSERVER_SHUTDOWN_DELAY=$1
fi
### Arrêt du serveur (world)
if [[ $WORLDSERVER_SHUTDOWN_DELAY > 0 ]];
then
echo "`date` LoA > Shutting down worldserver (delay: $WORLDSERVER_SHUTDOWN_DELAY sec)..." | tee -a $LOG_FILE
else
echo "`date` LoA > Shutting down worldserver..." | tee -a $LOG_FILE
fi
su northrend -c "/usr/bin/screen -S loa-world -X stuff \"server shutdown $WORLDSERVER_SHUTDOWN_DELAY\\r\""
while [[ $(pgrep "worldserver") != "" ]]; do
sleep 1s
done
echo "`date` LoA > Done." | tee -a $LOG_FILE
### Arrêt des services
echo "`date` LoA > Stopping services..." | tee -a $LOG_FILE
systemctl stop loa-auth loa-world | tee -a $LOG_FILE
echo "`date` LoA > Done." | tee -a $LOG_FILE
`
Archived author: Revision • Posted: 2022-05-17T17:58:41.988000+00:00
Original source
You can use a parameter rather than changing the script if you want the ability to quickly change the delay
Archived author: Revision • Posted: 2022-05-17T17:58:56.843000+00:00
Original source
never