Logo Khaganat
Traductions de cette page?:

Ceci est une ancienne révision du document !


Manager

Présentation d'un outil pour manipuler/gérer les process du serveur khaganat

Pre-requis

Il faut installer :

  • python3

Attention, dans la version de test on pointe sur mon repo khanat-code, a terme on sera sur la branche officielle

git clone https://git.khaganat.net/aleajactaest/khanat-code.git
cd khanat-code; git checkout feature/19-package-server-in-a-Docker-container; cd ..

programme

Serveur

Le serveur de management est géré par un script. Il est lancé en tâche de fond et attend les commandes

khanat-code/code/khaganat/tools/manage.py

Client

Il existe actuellement un client pour manipuler le serveur.

A terme, il existera un autre client pour manipuler le serveur. [objectif l'intégrer à l'outil Web de management de khaganat - django]

khanat-code/code/khaganat/tools/client.py

Installation

Controler la présence des scripts

  • khaganat/tools/manage.py
  • khaganat/tools/client.py

Création d'un certificat

La communication entre le client et le serveur s’effectue via une clef et un certificat. Cela sécurise la communication entre ce deux modules.

openssl req -nodes -x509 -newkey rsa:2048 -keyout "crt/key.pem" -out "crt/cert.pem" -days 365  -subj "/C=FR/ST=France/L=Paris/O=khaganat/CN=khaganat.org"

On aura deux fichier :

  • key.pem : clef
  • cert.pem : certificat

Configuration

La configuration se compose de deux parties.

  1. configuration général (port d'écoute, certificat, adresse réseau d'écoute
  2. configuration de chacun des programmes (commande, répertoire de base, taille de la log et taille du buffer
[config]
# Define port listen (default 8000)
port = 8000

# Generate key
# openssl req -nodes -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days 365 -subj "/C=FR/ST=France/L=Paris/O=khaganat/CN=khaganat.org"

# key
keyfile = /home/gameserver/khanat/key.pem

# certificate
certfile = /home/gameserver/khanat/cert.pem

# address listen (default all port)
address =

##############################
##############################
# List all program we manage #
##############################
##############################

##############################
# Admin Executor Service
##############################
[aes]

# command to launch the program
command = ryzom_admin_service -A/home/gameserver/khanat/server -C/home/gameserver/khanat/server -L/home/gameserver/log/khanat --nobreak --fulladminname=admin_executor_service --shortadminname=AES

# Path : where this program is launched
path = /home/gameserver/khanat/server/

# size buffer log for each program launched
sizelog = 1000

# Define other program

Utilisation

Serveur

Démarrer le serveur

nohup /home/gameserver/ext/khaganat/tools/manage.py --log info --show-log-console --filelog /home/gameserver/log/khanat/manager.log -c /home/gameserver/khanat/khaganat.cfg --launch-program 2>/dev/null 1>/dev/null 0</dev/zero &

Client

Status de tous les programmes

contrôle l'état de tous les programmes (retourne “started” ou “stopped”)

/home/gameserver/ext/khaganat/tools/client.py --key="/home/gameserver/khanat/key.pem" --cert="/home/gameserver/khanat/cert.pem" --log="info" --show-log-console --command="STATUSALL"

Démarre tous les programmes

Démarre tous les programmes (retourne “started”, “already-started” ou “crashed”)

/home/gameserver/ext/khaganat/tools/client.py --key="/home/gameserver/khanat/key.pem" --cert="/home/gameserver/khanat/cert.pem" --log="info" --show-log-console --command="STARTALL"

Arrête tous les programmes

Arrête tous les programmes (retourne “stopped”)

/home/gameserver/ext/khaganat/tools/client.py --key="/home/gameserver/khanat/key.pem" --cert="/home/gameserver/khanat/cert.pem" --log="info" --show-log-console --command="STOPALL"

Arrête le manager (et tous les programmes)

Arrête le manager (ainsi que tous les programmes)

/home/gameserver/ext/khaganat/tools/client.py --key="/home/gameserver/khanat/key.pem" --cert="/home/gameserver/khanat/cert.pem" --log="info" --show-log-console --command="SHUTDOWN"

Liste des programmes

Retourne la liste de tous les programmes disponible (démarré ou arrêté)

/home/gameserver/ext/khaganat/tools/client.py --key="/home/gameserver/khanat/key.pem" --cert="/home/gameserver/khanat/cert.pem" --log="info" --show-log-console --command="LIST"

Status d'un programme

contrôle l'état de d'un programme (retourne “started” ou “stopped”)

/home/gameserver/ext/khaganat/tools/client.py --key="/home/gameserver/khanat/key.pem" --cert="/home/gameserver/khanat/cert.pem" --log="info" --show-log-console --command="STATUS" --program="aes"

Démarre d'un programme

Démarre un programme (retourne “started” ou “stopped”)

/home/gameserver/ext/khaganat/tools/client.py --key="/home/gameserver/khanat/key.pem" --cert="/home/gameserver/khanat/cert.pem" --log="info" --show-log-console --command="START" --program="aes"

Arrête un programme

Arrête un programme (retourne “stopped”)

/home/gameserver/ext/khaganat/tools/client.py --key="/home/gameserver/khanat/key.pem" --cert="/home/gameserver/khanat/cert.pem" --log="info" --show-log-console --command="STOP" --program="aes"

Retourne la log d'un programme

Retourne les X derniers messages de la sortie standard (stdout) d'un programme.

firstline: première ligne que vous souhaitez récupérer

/home/gameserver/ext/khaganat/tools/client.py --key="/home/gameserver/khanat/key.pem" --cert="/home/gameserver/khanat/cert.pem" --log="info" --show-log-console --command="LOG" --program="aes" --firstline=0

Envoyer une entrée dans un programme

Envoie dans l'entrée du programme une action (Ex. help)

/home/gameserver/ext/khaganat/tools/client.py --key="/home/gameserver/khanat/key.pem" --cert="/home/gameserver/khanat/cert.pem" --log="info" --show-log-console --command="ACTION" --program="aes" --action="help all"

Souvent utilisé avec la commande “LOG” qui permet de voir le résultat.

Fonctionnement

Le serveur “manager” se met en écoute “style” https. Il attend les commandes et les envoie à ces fils (chaque fils gère un programme) Nous utilisons le format REST pour communiquer avec le serveur (les données envoyées au format json).

A Faire

  • Faisabilité d'une authentification pour séparer les droits en fonction des commandes
CC Attribution-Share Alike 4.0 International Driven by DokuWiki
fr/manager.1509660424.txt.gz · Dernière modification : 2021/12/03 19:18 (modification externe)

Licences Mentions légales Accueil du site Contact