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" = "egs" ] ||
[ "$NAME" = "ios" ] ||
[ "$NAME" = "gpms" ]
82 elif [ "$NAME" = "ais_fyros" ] ||
[ "$NAME" = "ais_matis" ] ||
[ "$NAME" = "ais_tryker" ] ||
[ "$NAME" = "ais_roots" ] ||
[ "$NAME" = "ais_zorai" ] ||
[ "$NAME" = "ais_ark" ]
87 echo "notifying $CWD/notify.sh ServiceStarted $NAME"
88 "$CWD/notify.sh" ServiceStarted
$NAME
90 export LC_ALL
=C
; unset LANGUAGE
92 if [[ "$USE_GDB" == "1" ]]
94 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" ]
96 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
98 echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$SHARD_PATH/lib $EXECUTABLE $CTRL_CMDLINE" > /tmp
/run_
$NAME
102 echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$SHARD_PATH/lib $EXECUTABLE $CTRL_CMDLINE" > /tmp
/run_
$NAME
105 schroot
-p -c atys
-- sh
/tmp
/run_
$NAME
107 "$CWD/notify.sh" ServiceStopped
$NAME
109 echo -----------------------------------------------------------------------
110 printf STOPPED
> $STATE_FILE
112 # consume (remove) the control file to allow start once
115 if [[ "$AUTO_RESTART" == "0" ]]
117 echo "Press ENTER to relaunch"
123 # either we haven't launched the app yet or we have launched and it has exitted
124 if [ -e $NEXT_CTRL_FILE ]
126 # we have some kind of relaunch directive lined up so deal with it
127 mv $NEXT_CTRL_FILE $CTRL_FILE
130 printf LAUNCH
> $CTRL_FILE