Skip to content

Instantly share code, notes, and snippets.

@redent
Last active February 8, 2021 09:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save redent/ea2d845a12ea039c23df1b0512d8baf1 to your computer and use it in GitHub Desktop.
Save redent/ea2d845a12ea039c23df1b0512d8baf1 to your computer and use it in GitHub Desktop.
Servidores Virtual Tabletop

Arrancar un servidor en un puerto

Se llama al script startServer.sh con el puerto como primer parámetro.

./startServer.sh <port>

Por ejemplo:

./startServer.sh 8899

Si no se especifica puerto, arrancará en el puerto 7777 por defecto.

Arrancar servidores por lotes

Se puede utilizar un bucle de Bash y sumar el índice a un número de puerto inicial, llamando al script startServer.sh descrito anteriorment. Por ejemplo, para desplegar 50 servidores desde el puerto 9001 al 9050:

for i in $(seq 1 50); do ./startServer.sh $((9000 + $i)); done

El primer número no tiene por qué ser un uno, por ejemplo podríamos desplegar 25 servidores, utilizando los puertos del 9051 al 9075 de esta forma:

for i in $(seq 51 75); do ./startServer.sh $((9000 + $i)); done

Parar servidores

Se puede parar un servidor en concreto haciendo uso del script stopServer.sh pasando como parámetro el puerto:

./stopServer.sh <port>

Por ejemplo:

./stopServer.sh 8899

Parar todos los servidores

Podemos parar todos los servidores mandando parando el supervisor que controla todos los procesos:

immortalctl halt "*"

Desplegar cliente WebGL

scp -pr '/home/redent/Documentos/D20_client/0.5.0/Web/Build'  root@dungeon20.com:/var/www/dungeon20/shared/public/system/tabletop/v0.5.0

ssh root@dungeon20.com

cd /var/www/dungeon20/shared/public/system/tabletop

# Deploy devel version
ln -snf v0.5.0 devel

Desplegar servidor

rsync -av /home/redent/Documentos/D20_server/0.5.0 root@vtt.dungeon20.com:

ssh root@vtt.dungeon20.com

lnf -sf 0.5.0 current

#!/usr/bin/env bash
if [ $# -eq 0 ]
then
PORT=7777
else
PORT="$1"
fi
HOST="vtt.dungeon20.com"
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
PID_FILE="$DIR/pids/$PORT.pid"
LOG_FILE="$DIR/logs/$PORT.log"
echo "Starting server at port $PORT"
nohup /root/Tabletop-Linux/Tabletop.x86_64 -batchmode -port $PORT -host $HOST > $LOG_FILE 2>1 & echo $! > $PID_FILE
#!/usr/bin/env bash
if [ $# -eq 0 ]
then
PORT=7777
else
PORT="$1"
fi
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
PID_FILE="$DIR/pids/$PORT.pid"
echo "Stoping server at port $PORT"
pkill -9 -F $PID_FILE
rm $PID_FILE
#!/usr/bin/env bash
if [ $# -eq 0 ]
then
PORT=7777
else
PORT="$1"
fi
WS_PORT=$((PORT + 1000))
WS_INNER_PORT=$((WS_PORT + 10000))
HOST="vtt.dungeon20.com"
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
PID_FILE="$DIR/pids/$PORT.pid"
LOG_FILE="$DIR/logs/$PORT.log"
VERSION=current
echo "Starting server at port $PORT"
immortal -l $LOG_FILE -P $PID_FILE /root/$VERSION/Tabletop-Linux-Server/Tabletop.x86_64 -batchmode -host $HOST -tcpPort $PORT -websocketPort $WS_INNER_PORT -publicWebsocketPort $WS_PORT
#!/usr/bin/env bash
if [ $# -eq 0 ]
then
PORT=7777
else
PORT="$1"
fi
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
PID_FILE="$DIR/pids/$PORT.pid"
PID=`cat $PID_FILE`
echo "Stoping server at port $PORT"
immortalctl stop $PID
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment