上传代码

This commit is contained in:
sk 2025-07-18 10:45:29 +08:00
parent 5c730ef25a
commit e121ebc791
10 changed files with 81 additions and 55 deletions

View File

@ -21,46 +21,62 @@ RUN go env -w GOPROXY=https://goproxy.cn,direct
RUN go mod tidy RUN go mod tidy
RUN go build -mod readonly -ldflags "-X 'framework/server.buildVersion=${VERSION}' -X 'framework/profile.Active=prod'" -o ./build/bin/ezs_center ./servers/user RUN go build -mod readonly -ldflags "-X 'framework/server.buildVersion=${VERSION}' -X 'framework/profile.Active=prod'" -o ./build/bin/ecs_center ./servers/user
RUN go build -mod readonly -ldflags "-X 'framework/server.buildVersion=${VERSION}' -X 'framework/profile.Active=prod'" -o ./build/bin/ezs_event ./servers/event RUN go build -mod readonly -ldflags "-X 'framework/server.buildVersion=${VERSION}' -X 'framework/profile.Active=prod'" -o ./build/bin/ecs_event ./servers/event
RUN go build -mod readonly -ldflags "-X 'framework/server.buildVersion=${VERSION}' -X 'framework/profile.Active=prod'" -o ./build/bin/ezs_game ./servers/game RUN go build -mod readonly -ldflags "-X 'framework/server.buildVersion=${VERSION}' -X 'framework/profile.Active=prod'" -o ./build/bin/ecs_game ./servers/game
RUN go build -mod readonly -ldflags "-X 'framework/server.buildVersion=${VERSION}' -X 'framework/profile.Active=prod'" -o ./build/bin/ezs_gate ./servers/gate RUN go build -mod readonly -ldflags "-X 'framework/server.buildVersion=${VERSION}' -X 'framework/profile.Active=prod'" -o ./build/bin/ecs_gate ./servers/gate
# Target user # Target ecs
FROM alpine:latest AS ezs_user FROM alpine:latest AS ecs
WORKDIR /app/ecs
WORKDIR /app/ecs/user COPY --from=builder /projects/go/ecs/app.sh app.sh
COPY --from=builder /projects/go/ecs/build/bin/ezs_user ./bin/ezs_user RUN chmod +x ./app.sh
CMD ./bin/ezs_user -help COPY --from=builder /projects/go/ecs/build/bin/ecs_user user/bin/ecs_user
COPY --from=builder /projects/go/ecs/build/bin/ecs_event event/bin/ecs_event
COPY --from=builder /projects/go/ecs/build/bin/ecs_game game/bin/ecs_game
COPY --from=builder /projects/go/ecs/build/bin/ecs_gate gate/bin/ecs_gate
CMD ./app.sh help
# Target event ## Target user
FROM alpine:latest AS ezs_event #FROM alpine:latest AS ecs_user
#
WORKDIR /app/ecs/event #WORKDIR /app/ecs/user
#
COPY --from=builder /projects/go/ecs/build/bin/ezs_event ./bin/ezs_event #COPY --from=builder /projects/go/ecs/build/bin/ecs_user ./bin/ecs_user
#
CMD ./bin/ezs_event -help #CMD ./bin/ecs_user -help
#
#
# Target game ## Target event
FROM alpine:latest AS ezs_game #FROM alpine:latest AS ezs_event
#
WORKDIR /app/ecs/game #WORKDIR /app/ecs/event
#
COPY --from=builder /projects/go/ecs/build/bin/ezs_game ./bin/ezs_game #COPY --from=builder /projects/go/ecs/build/bin/ezs_event ./bin/ezs_event
#
CMD ./bin/ezs_game -help #CMD ./bin/ezs_event -help
#
# Target gate #
FROM alpine:latest AS ezs_gate ## Target game
#FROM alpine:latest AS ezs_game
WORKDIR /app/ecs/gate #
#WORKDIR /app/ecs/game
COPY --from=builder /projects/go/ecs/build/bin/ezs_gate ./bin/ezs_gate #
#COPY --from=builder /projects/go/ecs/build/bin/ezs_game ./bin/ezs_game
CMD ./bin/ezs_gate -help #
#CMD ./bin/ezs_game -help
#
## Target gate
#FROM alpine:latest AS ezs_gate
#
#WORKDIR /app/ecs/gate
#
#COPY --from=builder /projects/go/ecs/build/bin/ezs_gate ./bin/ezs_gate
#
#CMD ./bin/ezs_gate -help

30
app.sh
View File

@ -1,10 +1,14 @@
#!/bin/bash -e #!/bin/bash -e
if [[ $# != 3 ]]; then usage() {
echo "Usage: app.sh \${command} \${server} \${id}" echo "Usage: app.sh \${command} \${server} \${id}"
echo " command: start/stop/restart" echo " command: start/stop/restart"
echo " server: the name of the server" echo " server: the name of the server"
echo " id: the number greater than zero of the server id" echo " id: the number greater than zero of the server id"
}
if [[ $# != 3 ]]; then
usage
exit 0 exit 0
fi fi
@ -12,37 +16,39 @@ CMD=$1
SVR=$2 SVR=$2
SID=$3 SID=$3
cd ${SVR}_${SID}
start_server() { start_server() {
pid=`ps -ef | grep ezs_${SVR} | grep ${SVR}_${SID}.json | awk '{print $2}'` cd ${SVR}
pid=`ps -ef | grep ecs_${SVR} | grep ${SVR}_${SID}.json | awk '{print $2}'`
if [ ! -z ${pid} ]; then if [ ! -z ${pid} ]; then
echo "The server '${SVR}' with id:${SID} is running." echo "The server '${SVR}' with id:${SID} is running."
exit 0 exit 0
fi fi
if [ ! -x ./bin/ezs_${SVR} ]; then if [ ! -x ./bin/ecs_${SVR} ]; then
chmod +x ./bin/ezs_${SVR} chmod +x ./bin/ecs_${SVR}
fi fi
nohup ./bin/ezs_${SVR} -conf ./conf/${SVR}_${SID}.json > ./ezs_${SVR}_${SID}.out 2>&1 & nohup ./bin/ecs_${SVR} -conf ./conf/${SVR}_${SID}.json > ./ecs_${SVR}_${SID}.out 2>&1 &
sleep 2 sleep 2
pid=`ps -ef | grep ezs_${SVR} | grep ${SVR}_${SID}.json | awk '{print $2}'` pid=`ps -ef | grep ecs_${SVR} | grep ${SVR}_${SID}.json | awk '{print $2}'`
if [ -z ${pid} ]; then if [ -z ${pid} ]; then
echo "The server '${SVR}' with id:${SID} start failed." echo "The server '${SVR}' with id:${SID} start failed."
tail -n30 ./bin/ezs_${SVR}_${SID}.out tail -n30 ./bin/ecs_${SVR}_${SID}.out
exit 1 exit 1
fi fi
echo "The server '${SVR}' with id:${SID} was started, pid: ${pid}" echo "The server '${SVR}' with id:${SID} was started, pid: ${pid}"
cd ..
} }
stop_server() { stop_server() {
pid=`ps -ef | grep ezs_${SVR} | grep ${SVR}_${SID}.json | awk '{print $2}'` pid=`ps -ef | grep ecs_${SVR} | grep ${SVR}_${SID}.json | awk '{print $2}'`
if [ ! -z ${pid} ]; then if [ ! -z ${pid} ]; then
kill ${pid} kill ${pid}
@ -67,6 +73,10 @@ case ${CMD} in
start_server start_server
exit 0 exit 0
;; ;;
help)
usage
exit 0
;;
*) *)
echo "Unknown command: ${CMD}" echo "Unknown command: ${CMD}"
exit 1 exit 1

View File

@ -21,8 +21,8 @@ SET /P VERSION=<./build.version
SET /A VERSION+=1 SET /A VERSION+=1
FOR %%i IN (user event game gate) DO ( FOR %%i IN (user event game gate) DO (
ECHO go build -ldflags "-X 'github.com/oylshe1314/framework/server.buildVersion=%VERSION%' -X 'framework/profile.Active=test'" -o %OUT_DIR%/%%i_1/bin/ezs_%%i ./servers/%%i ECHO go build -ldflags "-X 'github.com/oylshe1314/framework/server.buildVersion=%VERSION%' -X 'framework/profile.Active=test'" -o %OUT_DIR%/%%i_1/bin/ecs_%%i ./servers/%%i
go build -ldflags "-X 'github.com/oylshe1314/framework/server.buildVersion=%VERSION%' -X 'framework/profile.Active=test'" -o %OUT_DIR%/%%i_1/bin/ezs_%%i ./servers/%%i go build -ldflags "-X 'github.com/oylshe1314/framework/server.buildVersion=%VERSION%' -X 'framework/profile.Active=test'" -o %OUT_DIR%/%%i_1/bin/ecs_%%i ./servers/%%i
) )
IF %ERRORLEVEL% EQU 0 ECHO %VERSION% 1>./build.version IF %ERRORLEVEL% EQU 0 ECHO %VERSION% 1>./build.version

View File

@ -12,7 +12,7 @@
}, },
"mongoClient": { "mongoClient": {
"address": "mongodb://127.0.0.1:27017", "address": "mongodb://127.0.0.1:27017",
"database": "ezs_event_dev_1" "database": "ecs_event_dev_1"
}, },
"sdConfig": { "sdConfig": {
"servers": [ "servers": [

View File

@ -26,7 +26,7 @@
}, },
"mongoClient": { "mongoClient": {
"address": "mongodb://127.0.0.1:27017", "address": "mongodb://127.0.0.1:27017",
"database": "ezs_game_dev_1" "database": "ecs_game_dev_1"
}, },
"sdConfig": { "sdConfig": {
"servers": [ "servers": [

View File

@ -17,7 +17,7 @@
}, },
"mongoClient": { "mongoClient": {
"address": "mongodb://127.0.0.1:27017", "address": "mongodb://127.0.0.1:27017",
"database": "ezs_gate_dev_1" "database": "ecs_gate_dev_1"
}, },
"sdConfig": { "sdConfig": {
"servers": [ "servers": [

View File

@ -12,7 +12,7 @@
}, },
"mongoClient": { "mongoClient": {
"address": "mongodb://127.0.0.1:27017", "address": "mongodb://127.0.0.1:27017",
"database": "ezs_user_dev_1" "database": "ecs_user_dev_1"
}, },
"sdConfig": { "sdConfig": {
"servers": [ "servers": [