start in default with OpenNel-Manager, remove old option, create directory for gpms

This commit is contained in:
AleaJactaEst 2018-08-22 23:37:29 +02:00
parent bcbd34a4f5
commit 5d3961ae4f

View file

@ -16,6 +16,8 @@
# You should have received a copy of the GNU Affero General Public License # You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>. # along with this program. If not, see <https://www.gnu.org/licenses/>.
declare -i METHOD_START=0
usage() usage()
{ {
cat << EOF cat << EOF
@ -25,89 +27,12 @@ usage:$0 [options]
options: options:
-h, --help : Show this help -h, --help : Show this help
-d, --debug : Show debug message -d, --debug : Show debug message
--start-khanat-with-screen : start with screen --screen : start khanat with screen
--show-khanat-log : Show khanat log (after start) --opennel-manager : (default) start khanat with OpenNel-Manager
--show-all-log : Show all log (after start) [apache, mysql, khanat] --bash : launch bash (doesn't start khanat)
--show-status-nagios : show status (ater start)
--show-status : show status (ater start)
--bash-after-start : command bash after start
EOF EOF
} }
status_program()
{
pid=$(cat /home/gameserver/khanat/server/$1/$1.pid)
ps -p $pid >/dev/null
if [[ $? -eq 0 ]]
then
pidstate="ok"
else
pidstate="ko"
fi
state=$(cat /home/gameserver/khanat/server/$1/$1.state)
echo "$1 $2 [$state] pid:$pid => $pidstate"
}
status_all()
{
# aes : admin_executor_service.log
status_program 'aes' 'ryzom_admin_service'
# bms_master : backup_service.log
status_program 'bms_master' 'ryzom_backup_service'
# bms_pd_master
# status_program 'bms_pd_master' 'ryzom_backup_service'
# egs : entities_game_service.log
status_program 'egs' 'ryzom_entities_game_service'
# gpms : gpm_service.log
status_program 'gpms' 'ryzom_gpm_service'
# ios : input_output_service.log
status_program 'ios' 'ryzom_ios_service'
# rns : naming_service.log
status_program 'rns' 'ryzom_naming_service'
# rws : welcome_service.log
status_program 'rws' 'ryzom_welcome_service'
# ts : tick_service.log
status_program 'ts' 'ryzom_tick_service'
# ms : mirror_service.log
status_program 'ms' 'ryzom_mirror_service'
# ais_newbyland : ai_service.log
status_program 'ais_newbyland' 'ryzom_ai_service'
# mfs : mail_forum_service.log
status_program 'mfs' 'ryzom_mail_forum_service'
# su : shard_unifier_service.log
status_program 'su' 'ryzom_shard_unifier_service'
# fes : frontend_service.log
status_program 'fes' 'ryzom_frontend_service'
# sbs : session_browser_server.log
status_program 'sbs' 'ryzom_session_browser_service'
# lgs : logger_service.log
status_program 'lgs' 'ryzom_logger_service'
# mos
# status_program 'mos' 'ryzom_monitor_service'
# pdss
#status_program 'pdss' 'ryzom_pd_support_service'
# ras : admin_service.log
status_program 'ras' 'ryzom_admin_service'
}
function create_default_file_for_screen() function create_default_file_for_screen()
{ {
# on screen mode, we launch with root right # on screen mode, we launch with root right
@ -149,6 +74,12 @@ function create_default_file_for_screen()
create_dir_gameserver '/home/gameserver/khanat/server/ts' || exit 2 create_dir_gameserver '/home/gameserver/khanat/server/ts' || exit 2
} }
function create_default_file_for_opennel_manager()
{
create_dir_gameserver '/home/gameserver/log/khanat' || exit 2
create_dir_gameserver '/home/gameserver/khanat/server/gpms' || exit 2
}
##################### #####################
# MAIN # MAIN
##################### #####################
@ -166,34 +97,18 @@ do
set_debug 1 set_debug 1
shift shift
;; ;;
--start-khanat-with-screen) --screen)
METHOD_START=0 METHOD_START=0
shift shift
;; ;;
--show-khanat-log) --bash)
METHOD_START=1 METHOD_START=1
shift shift
;; ;;
--show-all-log) --opennel-manager)
METHOD_START=3
shift
;;
--show-status-nagios)
METHOD_START=2 METHOD_START=2
shift shift
;; ;;
--show-status)
METHOD_START=4
shift
;;
--bash-after-start)
METHOD_START=5
shift
;;
--start-with-manager)
METHOD_START=6
shift
;;
*) *)
msg_error "options '$1' not recognize" msg_error "options '$1' not recognize"
usage usage
@ -239,18 +154,6 @@ tmp=$(hostname -I)
export addressip=${tmp//[[:blank:]]/} export addressip=${tmp//[[:blank:]]/}
sudo sed -i -r 's/(FSListenHost)(.*)(=)(.*)(;)/FSListenHost = "'"$addressip"'";/g' $KHANAT_PATH/server/frontend_service.cfg || exit 2 sudo sed -i -r 's/(FSListenHost)(.*)(=)(.*)(;)/FSListenHost = "'"$addressip"'";/g' $KHANAT_PATH/server/frontend_service.cfg || exit 2
#####################
# Update configuration
#####################
msg_debug "Update configuration with new path"
newpath="$KHANAT_PATH/server/common/"
newpath=${newpath//\//\\\/}
for filecfg in $KHANAT_PATH/server/*.cfg
do
msg_debug "[$(basename $0):$LINENO] update $filecfg"
#sudo sed -i -r "s/..\/common\//$newpath/g" $filecfg
#sudo sed -i -r "s/..\/common\//common\//g" $filecfg
done
##################### #####################
# Reconfigure database # Reconfigure database
@ -286,55 +189,31 @@ WHERE domain_id = 12;" || exit 2
# Start khanat # Start khanat
##################### #####################
msg_debug "Start khanat" msg_debug "Start khanat"
if [ -f /home/gameserver/opennelmanager.flag ] if [ -f /home/gameserver/opennelmanager.flag ]
then then
rm /home/gameserver/opennelmanager.flag || exit 2 rm /home/gameserver/opennelmanager.flag || exit 2
fi fi
if [[ $METHOD_START -eq 0 ]] if [[ $METHOD_START -eq 0 ]]
then then
msg_debug "start with screen" msg_debug "start with screen"
source /home/gameserver/.bashrc; export RYZOM_PATH=$KHANAT_PATH; cd "$RYZOM_PATH"; $KHANAT_HOME/khanat/tools/scripts/linux/shard start source /home/gameserver/.bashrc; export RYZOM_PATH=$KHANAT_PATH; cd "$RYZOM_PATH"; $KHANAT_HOME/khanat/tools/scripts/linux/shard start
elif [[ $METHOD_START -eq 1 ]] elif [[ $METHOD_START -eq 1 ]]
then then
msg_debug "start with show-khanat-log" msg_debug "launch bash"
/opt/ext/servercontainer_launch_service.sh bash
sleep 10
tail -n+0 -f /home/gameserver/log/khanat/log.log
elif [[ $METHOD_START -eq 2 ]] elif [[ $METHOD_START -eq 2 ]]
then then
msg_debug "start with show-status-nagios"
/opt/ext/servercontainer_launch_service.sh
sleep 10
watch cat /home/gameserver/khanat/server/aes_nagios_report.txt
elif [[ $METHOD_START -eq 3 ]]
then
msg_debug "start with show-all-log"
/opt/ext/servercontainer_launch_service.sh
sleep 10
tail -n+0 -f /home/gameserver/log/apache2/* /home/gameserver/log/mysql/* /home/gameserver/log/khanat/*
elif [[ $METHOD_START -eq 4 ]]
then
msg_debug "start with status"
/opt/ext/servercontainer_launch_service.sh
sleep 10
watch /opt/ext/servercontainer_launch_status.sh --no-color
elif [[ $METHOD_START -eq 5 ]]
then
msg_debug "start with show-status"
/opt/ext/servercontainer_launch_service.sh
#sleep 10
bash
elif [[ $METHOD_START -eq 6 ]]
then
mkdir -p /home/gameserver/log/khanat || exit 2
msg_debug "start with OpenNelManager" msg_debug "start with OpenNelManager"
touch /home/gameserver/opennelmanager.flag touch /home/gameserver/opennelmanager.flag
create_default_file_for_opennel_manager
python3 -m pymanager.manager -c /home/gameserver/khanat/khaganat.cfg --log DEBUG --filelog /home/gameserver/log/khanat/OpenNelManager.log --launch-program & python3 -m pymanager.manager -c /home/gameserver/khanat/khaganat.cfg --log DEBUG --filelog /home/gameserver/log/khanat/OpenNelManager.log --launch-program &
#sleep 10 #sleep 10
#screen -t terminal /bin/bash -l #screen -t terminal /bin/bash -l
/bin/bash -l /bin/bash -l
else else
msg_error 'Bad option' msg_error 'Bad option (METHOD_START:$METHOD_START)'
exit 2 exit 2
fi fi