2 # ______ _____ _ _ _____ _
3 # | ___ \ / ___| | | | |_ _| | |
4 # | |_/ / _ _______ _ __ ___ \ `--.| |__ __ _ _ __ __| | | | ___ ___ | |___
5 # | / | | |_ / _ \| '_ ` _ \ `--. \ '_ \ / _` | '__/ _` | | |/ _ \ / _ \| / __|
6 # | |\ \ |_| |/ / (_) | | | | | | /\__/ / | | | (_| | | | (_| | | | (_) | (_) | \__ \
7 # \_| \_\__, /___\___/|_| |_| |_| \____/|_| |_|\__,_|_| \__,_| \_/\___/ \___/|_|___/
11 # Ryzom - MMORPG Framework <https://ryzom.com/dev/>
12 # Copyright (C) 2019 Winch Gate Property Limited
13 # This program is free software: read https://ryzom.com/dev/copying.html for more details
15 # This script is a service launcher that works with a command file
16 # to determine when to launch the application that it is responsible for
33 NAME_BASE
="$NAME/$NAME"
34 CTRL_FILE
=${NAME_BASE}_immediate.launch_ctrl
35 NEXT_CTRL_FILE
=${NAME_BASE}_waiting.launch_ctrl
36 STATE_FILE
=${NAME_BASE}.state
37 START_COUNTER_FILE
=${NAME_BASE}.start_count
40 echo ---------------------------------------------------------------------------------
41 echo Starting service launcher
42 echo ---------------------------------------------------------------------------------
43 printf "%-16s = " CMDLINE
; echo $CTRL_CMDLINE
44 printf "%-16s = " CTRL_FILE
; echo $CTRL_FILE
45 printf "%-16s = " NEXT_CTRL_FILE
; echo $NEXT_CTRL_FILE
46 printf "%-16s = " STATE_FILE
; echo $STATE_FILE
47 echo ---------------------------------------------------------------------------------
50 # reinit the start counter
51 echo 0 > $START_COUNTER_FILE
56 # see if the conditions are right to launch the app
60 # a control file exists so read it's contents
61 CTRL_COMMAND
=_$
(cat $CTRL_FILE)_
63 # do we have a 'launch' command?
64 if [ $CTRL_COMMAND = _LAUNCH_
]
67 # update the start counter
68 START_COUNTER
=$
(( $START_COUNTER + 1 ))
69 echo $START_COUNTER > $START_COUNTER_FILE
71 # we have a launch command so prepare, launch, wait for exit and do the housekeeping
72 echo -----------------------------------------------------------------------
73 echo Launching $
(pwd) $EXECUTABLE $CTRL_CMDLINE...
75 printf RUNNING
> $STATE_FILE
79 if [[ "$NAME" == "ais_fyros" ]] ||
[[ "$NAME" == "ais_matis" ]] ||
[[ "$NAME" == "ais_tryker" ]] ||
[[ "$NAME" == "ais_roots" ]] ||
[[ "$NAME" == "ais_zorai" ]] ||
[[ "$NAME" == "ais_ark" ]]
81 touch "$SHARD_PATH/logs/ai_service_${NAME}.log"
82 "$CWD/wait_and_notify.sh" "$SHARD_PATH/logs/ai_service_${NAME}.log" "[[ARK]] AIS UP" $NAME 0 &
84 elif [[ "$NAME" == "egs" ]]
86 touch "$SHARD_PATH/logs/entities_game_service.log"
87 "$CWD/wait_and_notify.sh" "$SHARD_PATH/logs/entities_game_service.log" "onAiInstanceReady : AI Instance 1 is up" $NAME 0 &
89 elif [[ "$NAME" == "ios" ]]
91 touch "$SHARD_PATH/logs/input_output_service.log"
92 "$CWD/wait_and_notify.sh" "$SHARD_PATH/logs/input_output_service.log" "cbDynChatAddChan: add channel : FACTION_MARAUDER" $NAME 0 &
94 elif [[ "$NAME" == "gpms" ]]
96 touch "$SHARD_PATH/logs/gpm_service.log"
97 "$CWD/wait_and_notify.sh" "$SHARD_PATH/logs/gpm_service.log" "cbCreateIndoorUnit : MSG: Creating indoor unit 256" $NAME 0 &
100 declare -A ServiceLogs
101 ServiceLogs
[aes
] = "admin_executor_service.log"
102 ServiceLogs
[bms_master
] = "backup_service.log"
103 ServiceLogs
[fes
] = "frontend_service.log"
104 ServiceLogs
[las
] = "log_analyser_service.log"
105 ServiceLogs
[lgs
] = "logger_service.log"
106 ServiceLogs
[mos
] = "monitor_service.log"
107 ServiceLogs
[ms
] = "mirror_service.log"
108 ServiceLogs
[ras
] = "admin_service.log"
109 ServiceLogs
[rns
] = "naming_service.log"
110 ServiceLogs
[rws
] = "welcome_service.log"
111 ServiceLogs
[sbs
] = "session_browser_server.log"
112 ServiceLogs
[su
] = "shard_unifier_service.log"
113 ServiceLogs
[ts
] = "tick_service.log"
115 touch "$SHARD_PATH/logs/${ServiceLogs[$NAME]}"
116 "$CWD/wait_and_notify.sh" "$SHARD_PATH/logs/${ServiceLogs[$NAME]}" "SERVICE: Service ready" $NAME 2 &
119 export LC_ALL
=C
; unset LANGUAGE
121 if [[ "$USE_GDB" == "1" ]]
123 if [[ "$NAME" == "egs" ]] ||
[[ "$NAME" == "ios" ]] ||
[[ "$NAME" == "ais_fyros" ]] ||
[[ "$NAME" == "ais_matis" ]] ||
[[ "$NAME" == "ais_tryker" ]] ||
[[ "$NAME" == "ais_roots" ]] ||
[[ "$NAME" == "ais_zorai" ]] ||
[[ "$NAME" == "ais_ark" ]] ||
[[ "$NAME" == "gpms" ]]
125 echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$SHARD_PATH/lib gdb -batch -ex 'set logging file $NAME/gdb_dump.txt' -ex 'set logging on' -ex 'run $CTRL_CMDLINE' -ex 'bt' $EXECUTABLE" > /tmp
/run_
$NAME
127 echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$SHARD_PATH/lib $EXECUTABLE $CTRL_CMDLINE" > /tmp
/run_
$NAME
131 echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$SHARD_PATH/lib $EXECUTABLE $CTRL_CMDLINE" > /tmp
/run_
$NAME
134 schroot
-p -c atys
-- sh
/tmp
/run_
$NAME
136 "$CWD/notify.sh" ServiceStopped
$NAME
138 echo -----------------------------------------------------------------------
139 printf STOPPED
> $STATE_FILE
141 # consume (remove) the control file to allow start once
144 if [[ "$AUTO_RESTART" == "0" ]]
146 echo "Press ENTER to relaunch"
152 # either we haven't launched the app yet or we have launched and it has exitted
153 if [ -e $NEXT_CTRL_FILE ]
155 # we have some kind of relaunch directive lined up so deal with it
156 mv $NEXT_CTRL_FILE $CTRL_FILE
159 printf LAUNCH
> $CTRL_FILE