diff --git a/Dockerfile b/Dockerfile index a383684..0e843b9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -21,46 +21,62 @@ RUN go env -w GOPROXY=https://goproxy.cn,direct 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/ezs_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/ezs_gate ./servers/gate +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/ecs_event ./servers/event +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/ecs_gate ./servers/gate -# Target user -FROM alpine:latest AS ezs_user +# Target ecs +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 -FROM alpine:latest AS ezs_event - -WORKDIR /app/ecs/event - -COPY --from=builder /projects/go/ecs/build/bin/ezs_event ./bin/ezs_event - -CMD ./bin/ezs_event -help - - -# Target game -FROM alpine:latest AS ezs_game - -WORKDIR /app/ecs/game - -COPY --from=builder /projects/go/ecs/build/bin/ezs_game ./bin/ezs_game - -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 \ No newline at end of file +## Target user +#FROM alpine:latest AS ecs_user +# +#WORKDIR /app/ecs/user +# +#COPY --from=builder /projects/go/ecs/build/bin/ecs_user ./bin/ecs_user +# +#CMD ./bin/ecs_user -help +# +# +## Target event +#FROM alpine:latest AS ezs_event +# +#WORKDIR /app/ecs/event +# +#COPY --from=builder /projects/go/ecs/build/bin/ezs_event ./bin/ezs_event +# +#CMD ./bin/ezs_event -help +# +# +## Target game +#FROM alpine:latest AS ezs_game +# +#WORKDIR /app/ecs/game +# +#COPY --from=builder /projects/go/ecs/build/bin/ezs_game ./bin/ezs_game +# +#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 diff --git a/app.sh b/app.sh index d8589c8..dc63d7f 100644 --- a/app.sh +++ b/app.sh @@ -1,10 +1,14 @@ #!/bin/bash -e +usage() { + echo "Usage: app.sh \${command} \${server} \${id}" + echo " command: start/stop/restart" + echo " server: the name of the server" + echo " id: the number greater than zero of the server id" +} + if [[ $# != 3 ]]; then - echo "Usage: app.sh \${command} \${server} \${id}" - echo " command: start/stop/restart" - echo " server: the name of the server" - echo " id: the number greater than zero of the server id" + usage exit 0 fi @@ -12,37 +16,39 @@ CMD=$1 SVR=$2 SID=$3 -cd ${SVR}_${SID} - 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 echo "The server '${SVR}' with id:${SID} is running." exit 0 fi - if [ ! -x ./bin/ezs_${SVR} ]; then - chmod +x ./bin/ezs_${SVR} + if [ ! -x ./bin/ecs_${SVR} ]; then + chmod +x ./bin/ecs_${SVR} 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 - 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 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 fi echo "The server '${SVR}' with id:${SID} was started, pid: ${pid}" + + cd .. } 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 kill ${pid} @@ -67,6 +73,10 @@ case ${CMD} in start_server exit 0 ;; + help) + usage + exit 0 + ;; *) echo "Unknown command: ${CMD}" exit 1 diff --git a/build.dev.bat b/build.dev.cmd similarity index 100% rename from build.dev.bat rename to build.dev.cmd diff --git a/build.prod.bat b/build.prod.cmd similarity index 100% rename from build.prod.bat rename to build.prod.cmd diff --git a/build.test.bat b/build.test.cmd similarity index 87% rename from build.test.bat rename to build.test.cmd index 9732c19..62d5c28 100644 --- a/build.test.bat +++ b/build.test.cmd @@ -21,8 +21,8 @@ SET /P VERSION=<./build.version SET /A VERSION+=1 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 - 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/ecs_%%i ./servers/%%i ) IF %ERRORLEVEL% EQU 0 ECHO %VERSION% 1>./build.version diff --git a/build_proto.bat b/build_proto.cmd similarity index 100% rename from build_proto.bat rename to build_proto.cmd diff --git a/conf/event_example.json b/conf/event_example.json index 3e6c274..3f64239 100644 --- a/conf/event_example.json +++ b/conf/event_example.json @@ -12,7 +12,7 @@ }, "mongoClient": { "address": "mongodb://127.0.0.1:27017", - "database": "ezs_event_dev_1" + "database": "ecs_event_dev_1" }, "sdConfig": { "servers": [ diff --git a/conf/game_example.json b/conf/game_example.json index 94c9a98..3bb47d4 100644 --- a/conf/game_example.json +++ b/conf/game_example.json @@ -26,7 +26,7 @@ }, "mongoClient": { "address": "mongodb://127.0.0.1:27017", - "database": "ezs_game_dev_1" + "database": "ecs_game_dev_1" }, "sdConfig": { "servers": [ diff --git a/conf/gate_example.json b/conf/gate_example.json index 567f947..3486236 100644 --- a/conf/gate_example.json +++ b/conf/gate_example.json @@ -17,7 +17,7 @@ }, "mongoClient": { "address": "mongodb://127.0.0.1:27017", - "database": "ezs_gate_dev_1" + "database": "ecs_gate_dev_1" }, "sdConfig": { "servers": [ diff --git a/conf/user_example.json b/conf/user_example.json index 0e3bc58..b94d1f5 100644 --- a/conf/user_example.json +++ b/conf/user_example.json @@ -12,7 +12,7 @@ }, "mongoClient": { "address": "mongodb://127.0.0.1:27017", - "database": "ezs_user_dev_1" + "database": "ecs_user_dev_1" }, "sdConfig": { "servers": [