server running in background

This commit is contained in:
Mohd-
2025-03-07 15:11:34 +03:00
parent 33a2253e3d
commit 9678b1222e
4 changed files with 71 additions and 16 deletions
+21
View File
@@ -0,0 +1,21 @@
# HearthMod Build Commands and Code Guidelines
## Build Commands
- `docker-compose up --build` - Build and start the project container
- `bash docker_ctl.sh compile` - Compile and install server stack
- `bash docker_ctl.sh start` - Start server stack
- `bash docker_ctl.sh stop` - Stop server stack
- Component-specific: `cd hm_gameserver && make`
- Base library: `make -C ../hm_base target=game`
## Code Style Guidelines
- **Indentation**: 4 spaces for C/C++/Python
- **Naming**:
- C: snake_case for functions/variables, UPPER_SNAKE_CASE for constants
- C++: camelCase for methods/variables, UPPER_SNAKE_CASE for constants
- Structs use _s suffix, enums use _e suffix
- **Headers**: System includes first, then project includes
- **Error handling**: Functions return int (0=success, negative=failure)
- **Logging**: Use `hm_log(LOG_LEVEL, log_instance, "message")`
- **Memory**: Always free allocated resources, use pooled allocation when possible
- **Initialization**: Follow component-specific init/cleanup patterns
+6 -6
View File
@@ -21,15 +21,15 @@ case $1 in
;;
start)
$CMD mkdir -p /app/hm_log
# Start the servers
$CMD /app/hm_gameserver/hm_gameserver --log=/app/hm_log/hm_gameserver_$(date +%s).log
$CMD /app/hm_lobbyserver/hm_lobbyserver --gameserver=104.131.186.231 --log=/app/hm_log/hm_lobbyserver_$(date +%s).log
# Start the servers in background with -d flag
docker exec -d hearthmod /app/hm_gameserver/hm_gameserver --log=/app/hm_log/hm_gameserver_$(date +%s).log
docker exec -d hearthmod /app/hm_lobbyserver/hm_lobbyserver --gameserver=104.131.186.231 --log=/app/hm_log/hm_lobbyserver_$(date +%s).log
# Start stud
$CMD /app/hm_stud/stud /app/hm_stud/cert/test.com.pem
docker exec -d hearthmod /app/hm_stud/stud /app/hm_stud/cert/test.com.pem
# Start fcgi
$CMD spawn-fcgi -d /app/hm_web/ -f /app/hm_web/app.py -a 127.0.0.1 -p 9002
docker exec -d hearthmod spawn-fcgi -d /app/hm_web/ -f /app/hm_web/app.py -a 127.0.0.1 -p 9002
# Start nginx
$CMD /app/hm_nginx/objs/nginx
docker exec -d hearthmod /app/hm_nginx/objs/nginx
docker exec -d hearthmod /bin/bash -c 'cd /app/hm_sunwell && nodejs examples/server hm_sunwell > /app/hm_log/nodejs_server_$(date +%s).log 2>&1'
;;
stop)
+29 -10
View File
@@ -1,15 +1,34 @@
#!/bin/bash
# Sleep for a few seconds (if needed)
# sleep 5
# compiling
# Start Couchbase Server
if [ "$(whoami)" = "couchbase" ]; then
exec /opt/couchbase/bin/couchbase-server -- -kernel global_enable_tracing false -noinput
else
exec chpst -ucouchbase /opt/couchbase/bin/couchbase-server -- -kernel global_enable_tracing false -noinput
fi
cd /app/hm_stud && make && rm -rf cert/test* && cd cert && sh gen_cert.sh
make -C /app/hm_gameserver
make -C /app/hm_lobbyserver
cd /app/hm_nginx && sed "s@\/usr\/local\/web@$(pwd)\/..\/hm_web\/@" conf/hm_nginx.conf > conf/nginx.conf && ./configure --with-http_ssl_module && make && make install
cd /app/hm_sunwell/examples && npm install
# Keep the script running to prevent the container from exiting
# tail -f /dev/null
# start
mkdir -p /app/hm_log
# Start the servers
/app/hm_gameserver/hm_gameserver --log=/app/hm_log/hm_gameserver_$(date +%s).log
/app/hm_lobbyserver/hm_lobbyserver --gameserver=104.131.186.231 --log=/app/hm_log/hm_lobbyserver_$(date +%s).log
# Start stud
/app/hm_stud/stud /app/hm_stud/cert/test.com.pem
# Start fcgi
spawn-fcgi -d /app/hm_web/ -f /app/hm_web/app.py -a 127.0.0.1 -p 9002
# Start nginx
/app/hm_nginx/objs/nginx
/bin/bash -c 'cd /app/hm_sunwell && nodejs examples/server hm_sunwell > /app/hm_log/nodejs_server_$(date +%s).log 2>&1' &
# bucket create
/opt/couchbase/bin/couchbase-cli bucket-create -c "localhost:8091" --bucket=hbs --bucket-password=aci --bucket-type=couchbase --bucket-ramsize=200 --bucket-replica=1 --wait
# bucket restore
/opt/couchbase/bin/cbrestore /app/hm_database/hbs http://localhost:8091/ --bucket-source=hbs
tail -f /dev/null
+15
View File
@@ -0,0 +1,15 @@
#!/bin/bash
# Sleep for a few seconds (if needed)
# sleep 5
# Start Couchbase Server
if [ "$(whoami)" = "couchbase" ]; then
exec /opt/couchbase/bin/couchbase-server -- -kernel global_enable_tracing false -noinput
else
exec chpst -ucouchbase /opt/couchbase/bin/couchbase-server -- -kernel global_enable_tracing false -noinput
fi
# Keep the script running to prevent the container from exiting
# tail -f /dev/null