Forum

> > CS2D > Servers > SSH servers and managing
Forums overviewCS2D overview Servers overviewLog in to reply

English SSH servers and managing

10 replies
To the start Previous 1 Next To the start

old SSH servers and managing

_Yank
User Off Offline

Quote
Greetings unreal software.
Since I'm very beginner to ssh based servers or VPS, whatever, I need some good advices. I know the most part of the basics so my doubt is not that how to start a server or similar.

I have 3 servers running on the VPS. Here is it's file tree :
More >


The bash script code is :
1
2
3
4
5
6
7
#!/bin/bash

while :
do
/home/cs2d/run
sleep 1
done
So the 5th line ( the directory ) changes depending on the server.
It checks if the server process is "on" then if it isn't it launches the server. It is very effective !

What I do to launch the server is, type "screen", to open a new screen. Then type "sudo sh /home/scripts/auto.sh". Then press Ctrl + C to open a new window and just do same i did before, just change the directory of bash file to execute to bash script of second server. Repeat the last process more 1 time, changing the bash script to run to the bash file of third server.

Resuming, I open a screen session, launch the server script and open another window to other 2 servers launching its bash script.

Actually I want to know if I'm starting/launching the server with the lighter way. If there is better ways, I want to see the console output and check if the server is online/running every 10 seconds or close.

And since I'm only at my personal PC at weekends, in most week days if I'm online is because I'm on a library. Since most of library's i go have proxy it is hard to use putty or similar. So I would like if someone could help or even make me a very simple cs2d server managing tool through HTML and PHP like cs2d we interface but a lot simpler. I just want something where I can write a password and if it's correct I can kill the server process leading to the server restart ( bash script ). It doesn't needs to be fancy

Also take this opportunity to ask if there is a way to check if the client has a specific server resource ( downloaded from servertransfer.lst )

We'll that's it, sorry for the dictionary I wrote here, just wanted to be detailed

Thanks !
edited 1×, last 10.02.14 10:38:14 pm

old Re: SSH servers and managing

ohaz
User Off Offline

Quote
The easiest way to periodically check if the server is still running is a cronjob. The "cron" software is a time-based scheduler.
From thread cs2d How open the CS2D server on Ubuntu?:
user ohaz has written
Easiest way to check if the server is running is by using a crontab and a script:
script:
1
2
3
4
5
6
7
8
9
10
11
12
13
#!/usr/bin/env bash

PIDFILE="$HOME/tmp/cs2d_dedicated.pid"

if [ -e "${PIDFILE}" ] && (ps -u $USER -f | grep "[ ]$(cat ${PIDFILE})[ ]"); then
  echo "Already running."
  exit 99
fi

$HOME/cs2d/cs2d_dedicated & > $HOME/tmp/cs2d_dedicated.log &

echo $! > "${PIDFILE}"
chmod 644 "${PIDFILE}"
Put this script somewhere in your home folder or inside the cs2d_dedicated folder and call it cs2d_starter
Then you just have to add a crontab line. To do that, enter
crontab -e
and add
1
* * * * * /home/cs2duser/cs2d/cs2d_starter
Of course you have to replace the path with the path your cs2d script is in.
This leads to the script above being executed every minute. The script then tests if the cs2d server is running, and, if not, is starting it.

You just have to modify this script a bit. Fix the folders and, of course, use crontab -e as the correct user for each server.

old Re: SSH servers and managing

Torque
User Off Offline

Quote
Quote
Also take this opportunity to ask if there is a way to check if the client has a specific server resource ( downloaded from servertransfer.lst )


I don't know exactly what you want with this. But in the logs it will mention which files the server sends to which player. You can use the lua hook: log(text) , to get that information. I hope that'll put you on the right track.

old Re: SSH servers and managing

_Yank
User Off Offline

Quote
@user ohaz Without that bash script checking at least every 3 seconds, how will that cs2d webinterface that i said, work ? I just dont wanted to use htop and similiar because it logs the output to a file. Im afraid if the file size gets to big and it reduces the server performance.

Actually i have a simple page ( http://5.231.39.147 ) just to share the serverstats file. I just want a simple page with a simple user system where I can kill the server process.

@user Torque: Oh, you are such a genius !
I forget that i could do that

Anyway, thank you guys.
edited 3×, last 11.02.14 03:02:29 pm

old Re: SSH servers and managing

sheeL
User Off Offline

Quote
user ohaz has written
The easiest way to periodically check if the server is still running is a cronjob. The "cron" software is a time-based scheduler.
From thread cs2d How open the CS2D server on Ubuntu?:
user ohaz has written
Easiest way to check if the server is running is by using a crontab and a script:
script:
1
2
3
4
5
6
7
8
9
10
11
12
13
#!/usr/bin/env bash

PIDFILE="$HOME/tmp/cs2d_dedicated.pid"

if [ -e "${PIDFILE}" ] && (ps -u $USER -f | grep "[ ]$(cat ${PIDFILE})[ ]"); then
  echo "Already running."
  exit 99
fi

$HOME/cs2d/cs2d_dedicated & > $HOME/tmp/cs2d_dedicated.log &

echo $! > "${PIDFILE}"
chmod 644 "${PIDFILE}"
Put this script somewhere in your home folder or inside the cs2d_dedicated folder and call it cs2d_starter
Then you just have to add a crontab line. To do that, enter
crontab -e
and add
1
* * * * * /home/cs2duser/cs2d/cs2d_starter
Of course you have to replace the path with the path your cs2d script is in.
This leads to the script above being executed every minute. The script then tests if the cs2d server is running, and, if not, is starting it.

You just have to modify this script a bit. Fix the folders and, of course, use crontab -e as the correct user for each server.


dude, this script not works

old Re: SSH servers and managing

Torque
User Off Offline

Quote
Most probably it does work and you do not know how to use it sheeL.

@SaskSlayer: There is a functional webinterface uploaded in the filearchive here somewhere. Perhaps you could use that, or modify it to your own needs. You should probably be careful about safety though, there's a lot of toddlers out there who want to stomp your metaphorical sandcastle.

old Re: SSH servers and managing

_Yank
User Off Offline

Quote
@user Torque: I know, actually I use it, it does not work but it stills not being what I wanted at all but sure, when I got time will try to look its code and modify it.

old Re: SSH servers and managing

sheeL
User Off Offline

Quote
user Torque has written
Most probably it does work and you do not know how to use it sheeL.

@SaskSlayer: There is a functional webinterface uploaded in the filearchive here somewhere. Perhaps you could use that, or modify it to your own needs. You should probably be careful about safety though, there's a lot of toddlers out there who want to stomp your metaphorical sandcastle.



I Know how use it, in this code, have a problem, is not detecting the PID

P.S = Webinterface is bugged

old Re: SSH servers and managing

sixpack
User Off Offline

Quote
ProTip:
/home/ folder is not meant for files. It is made for users. Unless you have 3 users on the VM running each one its own server process, then consider moving the files somewhere else.

ProTip2:
NEVER run a cs2d server as either uid=0,euid=0, which means do NOT run servers using sudo or when logged in as the user 'root'.
You can find out which user you are by typing id and checking the output.

old Server management

KimKat
GAME BANNED Off Offline

Quote
I've created a Bash script which automatically restarts the game server if the process is not existant or if it's not possible to get a successful response back via netcat from the process socket. It works great at times but I'm planning to update it further to make it more persistent. I use some external programs such as parallel it allows you to launch multiple game servers simultaneously. However my Bash script doesn't yet support multi-server abilities. I have some basic multi-server handling functionality written into it however. I might publish it later as it'll benefit server hosts who might want their server(s) running 24/7. It will be good.

My setup >
edited 5×, last 13.02.14 02:12:35 am

Admin/mod comment

CS2D server management tools
To the start Previous 1 Next To the start
Log in to reply Servers overviewCS2D overviewForums overview