Closed kevATin closed 4 years ago
Two methods you could try without me having to make changes:
$HOME/altitude
ALTITUDE_ROOT
in the script before each server start:Put this into $HOME/bin/start_alti_mmorpg.sh
#!/bin/sh
ALTITUDE_ROOT=$HOME/server1 $HOME/bin/alti+server
ALTITUDE_ROOT=$HOME/server2 $HOME/bin/alti+server
ALTITUDE_ROOT=$HOME/server3 $HOME/bin/alti+server
ALTITUDE_ROOT=$HOME/server4 $HOME/bin/alti+server
Or, if you want it dynamic:
#!/bin/sh
for server in $HOME/server*; do
ALTITUDE_ROOT=$server $HOME/bin/alti+server
done
Will any of these methods work for you?
Handling dozens of users wouldn't be much more convenient to me; but a master script sounds good, because I already expected I'd need one to coordinate inter-server features. After half a day of reading up on bash scripting, and screen; all things I should've done long ago; I managed to get this done, which seems to work fine so far. Took me way too long to fix all the errors I ended up producing (shoutout to iod and list for their advice~). I'll continue tomorrow or so; if you've got improvement ideas let me know~
#!/bin/bash
echo "Altitude MMORPG Server Network Controller"
function start {
for server in ./mmorpg_*; do
dir=${server##*/}
ALTITUDE_ROOT=$server screen -AdmS $dir-AMSNC -t $dir ./alti+server
done
}
function stop {
echo "Close all *-AMSNC screens"
}
if [ $1 = start ]; then
start
elif [ $1 = stop ]; then
stop
elif [ $1 = restart ]; then
start
stop
elif [ $1 = status ]; then
echo "prints the status of all servers to amsnc_status file"
else
echo "The allowed options are start, stop, restart, and status."
fi
I feel like the start
function should have for server in ./mmorpg_*; do
or something like that. Without wildcards, it should only match one thing.
Your way will work, I do things a little differently. I do use different users, but here is the end of my screen startup file .screenrc-altitude
:
sessionname altitude
width -d 80
height -d 31
screen -t ft+srv 0 sudo -u funkytown -i
stuff 'stty rows 30 columns 80^M'
stuff 'bin/alti+server^M'
screen -t ft+sh 1 sudo -u funkytown -i
stuff 'stty rows 30 columns 80^M'
stuff 'cd servers^M'
sleep 5
screen -t cp+srv 2 sudo -u coopplus -i
stuff 'stty rows 30 columns 80^M'
stuff 'bin/alti+server^M'
screen -t cp+sh 1 sudo -u coopplus -i
stuff 'stty rows 30 columns 80^M'
stuff 'cd servers^M'
sleep 5
screen -t ca+srv 2 sudo -u coopadv -i
stuff 'stty rows 30 columns 80^M'
stuff 'bin/alti+server^M'
screen -t ca+sh 1 sudo -u coopadv -i
stuff 'stty rows 30 columns 80^M'
stuff 'cd servers^M'
sleep 5
screen -t fb+srv 2 sudo -u football -i
stuff 'stty rows 30 columns 80^M'
stuff 'bin/alti+server^M'
screen -t fb+sh 1 sudo -u football -i
stuff 'stty rows 30 columns 80^M'
stuff 'cd servers^M'
sleep 5
select 0
Then, I have a systemd config file which starts screen when the server boots:
[Unit]
Description=Startup Altitude
After=default.target
[Service]
User=biellt
WorkingDirectory=/home/biellt
ExecStart=/usr/bin/screen -D -m -c .screenrc-altitude
ExecStop=/usr/bin/screen -S altitude -X quit
[Install]
WantedBy=default.target
I feel like the start function should have for server in ./mmorpg_*; do or something like that. Without wildcards, it should only match one thing.
You mean the function itself should always only start one server, and the if condition with start just calls the start function over and over again for each folder? Doesn't seem to me like it would make much of a difference whether the cycling through folders login is inside the if condition or inside the start function~ Also then I would have to replicate that part for the restart option; I guess I could make another function that does the cycling? Seems unnecessarily complicated to me.
.screenrc-altitude
Looks interesting; when I read through screen guides I tried to avoid that config file because I feel more comfortable setting everything up in my script :D Btw which server is funkytown? Team+, right?; I believe I remember you saying that MapQA runs separately because it's for testing.
The RPi isn't supposed to reboot very often; also sometimes I might not want the server to start, so auto-start at boot isn't something I want right now.
I feel like the start function should have for server in ./mmorpg_*; do or something like that. Without wildcards, it should only match one thing.
You mean the function itself should always only start one server, and the if condition with start just calls the start function over and over again for each folder?
No, I meant I think you have a coding problem. It looks like it is fixed, though. Maybe you edited the message to add the asterisk, but I was looking at it before you did that? Not sure, it looks fine now.
.screenrc-altitude
Looks interesting; when I read through screen guides I tried to avoid that config file because I feel more comfortable setting everything up in my script :D
The script is good too, it is just a matter of preference. I went my way because that way I could just start screen up as a system service, and it would automatically start up all the sub alti+server processes. There are many solutions to this problem, and yours is good too.
Btw which server is funkytown? Team+, right?; I believe I remember you saying that MapQA runs separately because it's for testing.
Yes, funkytown was the original name of Team+, before I wrote all the "+" features into my code. At that time, all my server really did was start maps up with different view and plane scales.
Ah I see, github was messing with my formatting and I tried to fix that, but I'm sure I didn't touch that "*", maybe github sometimes hides it outside of code blocks and shows it now that it's one? No idea;
So to make the MMORPG idea work I'll need lots of maps which all need to run at the same time, ie I'll need lots of servers dedicated to individual maps. Editing the $INSTALL_ROOT setting in the alti+server file would work fine, but doing that for more than a dozen servers could quickly get tedious, especially if I later need to rename some directories (I have them named after the map they'll be running, I think that's the best way to maintain overview.)
Could you add the ability use a relative path for that? If that's already possible, then could you tell me how to set alti+server to use the altitude directory laying in the same directory as alti+server, or maybe if alti+server is laying inside the altitude folder, because I can't seem to get it to work..