fix a few memory leaks and cppcheck detected errors - more in bugreport
[client-tools.git] / exe / linux / designcluster
blobffdb968ba16ac8c2b5bbe00752b1b0b776bf3cc4
1 #!/bin/bash
3 CLUSTER_NAME=DesignGalaxy
4 CENTRAL_SERVER_ADDRESS=$HOSTNAME
5 GAME_SCENE=tatooine.trn
6 LOGIN_SERVER_ADDRESS=swo-dev6.station.sony.com
7 EXE_DIR=/swo/swg/current/exe/linux
8 CENTRAL_PLANET_PORT=44475
9 CENTRAL_GAME_PORT=44471
11 kill_servers()
13 killall CentralServer_r &>/dev/null
14 killall CentralServer_d &>/dev/null
15 killall addr2line &>/dev/null
18 get_free_port()
20 PORT=(RANDOM + 1024)
21 ((PORT=$PORT+1))
22 AVAIL=`netstat -aut|grep $PORT`
23 while [ -n "$AVAIL" ];
26 ((PORT=RANDOM))
27 AVAIL=`netstat -aut|grep $PORT`
29 done
30 echo $PORT
33 run_central()
35 cd $EXE_DIR
36 echo "** Starting CentralServer at " $(date +"%Y%m%d-%k.%M.%S") >> /swo/swg/CentralServer.log
37 ./CentralServer_d -- \
38 -s CentralServer \
39 loginServerAddress=$LOGIN_SERVER_ADDRESS \
40 clusterName=$CLUSTER_NAME \
41 gameServicePort=$CENTRAL_GAME_PORT \
42 planetServicePort=$CENTRAL_PLANET_PORT \
43 >> /swo/swg/CentralServer.log 2>&1 &
46 run_connection()
48 cd $EXE_DIR
49 echo "** Starting ConnectionServer at " $(date +"%Y%m%d-%k.%M.%S") >> /swo/swg/ConnectionServer.log
50 ./ConnectionServer_d -- \
51 -s ConnectionServer \
52 clusterName=$CLUSTER_NAME \
53 loginServerAddress=$LOGIN_SERVER_ADDRESS \
54 centralServicePort=44482 \
55 clientServicePort=44483 \
56 gameServicePort=44484 \
57 >> /swo/swg/ConnectionServer.log 2>&1 &
60 run_dbprocess()
62 cd $EXE_DIR
63 echo "** Starting DBProcess at " $(date +"%Y%m%d-%k.%M.%S") >> /swo/swg/dbprocess.log
64 ./SwgDatabaseServer_d -- \
65 -s dbProcess \
66 centralServerAddress=$CENTRAL_SERVER_ADDRESS \
67 centralServerPort=$CENTRAL_GAME_PORT \
68 useTemplates=1 \
69 databaseProtocol=OCI \
70 databaseUID=designcluster \
71 databasePWD=changeme \
72 DSN=swodb \
73 >> /swo/swg/SwgDatabaseServer.log 2>&1 &
76 run_gameserver()
78 cd $EXE_DIR
79 echo "** Starting GameServer at " $(date +"%Y%m%d-%k.%M.%S") >> /swo/swg/SwgGameServer.log
80 ./SwgGameServer_d -- @../../exe/shared/servercommon.cfg @combat.cfg \
81 -s GameServer sceneID=tatooine \
82 centralServerAddress=$CENTRAL_SERVER_ADDRESS \
83 centralServerPort=$CENTRAL_GAME_PORT \
84 groundScene=terrain/$GAME_SCENE \
85 clusterName=$CLUSTER_NAME \
86 useTemplates=1 \
87 javaLibPath=/usr/noScriptsOnBaseServer \
88 scriptPath=../../data/sku.0/sys.server/plt.shared/loc.shared/compiled/game \
89 useRemoteDebugJava=0 \
90 javaDebugPort=0 \
91 -s SharedFoundation \
92 frameRateLimit=4 \
93 warningCallStackDepth=0 \
94 -s SharedDebug \
95 lookupCallStack=1 \
96 >> /swo/swg/SwgGameServer.log 2>&1 &
99 run_planetserver()
101 cd $EXE_DIR
102 echo "** Starting PlanetServer at " $(date +"%Y%m%d-%k.%M.%S") >> /swo/swg/PlanetServer.log
103 ./PlanetServer_d -- \
104 -s PlanetServer sceneID=tatooine \
105 clusterName=$CLUSTER_NAME \
106 centralServerPort=$CENTRAL_PLANET_PORT \
107 centralServerAddress=$CENTRAL_SERVER_ADDRESS \
108 >> /swo/swg/PlanetServer.log 2>&1 &
111 fatality()
113 CRASHDIR="/swo/swg/CRASH-"`date +"%Y%m%d-%k.%M.%S"`
114 echo ""
115 echo "**********************************************************************"
116 echo "** !!FATAL WARNING FATAL WARNING FATAL WARNING FATAL WARNING!!"
117 echo "**"
118 echo "** $1 "
119 echo "**"
120 echo "** Server is no longer running. It failed to properly start."
121 echo "** If this is an unknown bug, advise the server development team."
122 echo "**"
123 echo "** A crash directory called $CRASHDIR"
124 echo "** is being created, logs and the core file will be placed in "
125 echo "** $CRASHDIR"
126 echo "**"
127 echo "**********************************************************************"
128 echo ""
129 echo -n "Killing servers ..."
130 mkdir $CRASHDIR
131 cp /swo/swg/*.log $CRASHDIR
132 cp /swo/swg/current/exe/linux/core $CRASHDIR
133 kill_servers
134 echo "done."
138 #-----------------------------------------
139 #-- parse options
140 #-----------------------------------------
142 show_usage ()
145 echo "Options:"
146 echo " -h help"
147 echo " -s <scene> scenefile (default: $GAME_SCENE)"
148 echo " -x <exe dir> executable dir name (default: $EXE_DIR)"
149 echo " -n <nbname> nbname dir (default: $NBNAME)"
152 while getopts "hs:x:n:" arg
154 case $arg in
155 "s")
156 GAME_SCENE=$OPTARG
157 echo "Setting Game Scene to: $GAME_SCENE"
159 "x")
160 EXE_DIR=$OPTARG
161 echo "Setting Executable Dir to: $EXE_DIR"
163 "h")
164 show_usage;
167 show_usage;
169 esac
170 done
172 #-----------------------------------------
173 #-----------------------------------------
175 echo -n "Killing all servers you own... "
176 kill_servers
177 echo "done"
178 echo
179 echo "Checking database setup..."
180 cd /swo/swg/current/exe/linux
181 make -f database.mak
182 echo
183 echo "Port selection:"
185 echo " Central Server: game=$CENTRAL_GAME_SERVICE_PORT planet=$CENTRAL_PLANET_SERVICE_PORT"
186 echo " Connection Server: central=$CONNECTION_CENTRAL_SERVICE_PORT client=$CONNECTION_CLIENT_SERVICE_PORT game=$CONNECTION_GAME_SERVICE_PORT"
187 echo ""
189 echo -n "Starting central server ... "
190 run_central
191 echo "done."
192 sleep 3
193 echo -n "Starting connection server ... "
194 run_connection
195 echo "done."
196 sleep 2
197 echo -n "Starting database process ... "
198 run_dbprocess
199 echo "done."
200 sleep 2
201 echo -n "Starting planet server ... "
202 run_planetserver
203 echo "done."
204 sleep 2
205 echo -n "Starting game server ... "
206 run_gameserver
208 # Check for problems during startup
209 sleep 2
210 #if [ -z "`ps --User $USER | grep centralserver`" ]; then
212 # fatality "Central Server";
214 #elif [ -z "`ps --User $USER | grep connectionser`" ]; then
216 # fatality "Connection Server";
218 #elif [ -z "`ps --User $USER | grep dbprocess`" ]; then
220 # fatality "DB Process";
222 #elif [ -z "`ps --User $USER | grep gameserver`" ]; then
224 # fatality "Game Server"
226 #else
228 echo "done"
229 echo ""
230 echo "**********************************************************************"
231 echo "You may now connect to your game cluster [ $CLUSTER_NAME ]."
232 echo "Your client configuration should have an entry "
233 echo "loginServerAddress=$LOGIN_SERVER_ADDRESS "
234 echo ""
235 echo "If you are connecting to a different login server"
236 echo "ensure that servercommon.cfg in your depot reflects the"
237 echo "alternate server address, and that your client config"
238 echo "matches."
239 echo ""
240 echo "Contact Justin Randall or Chris Mayer if you are having trouble"
241 echo "**********************************************************************"