Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #56

Merged
merged 16 commits into from
Sep 22, 2024
Merged

Dev #56

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ set(ProjectName "startup")
file(GLOB soruces src/*.cc)
file(GLOB headers src/*.h)
file(GLOB_RECURSE proto ./src/proto/*.proto)
file(GLOB_RECURSE pycli ./src/pycli/*.py)
file(GLOB_RECURSE lua ./src/lua/*.lua)
file(GLOB_RECURSE plugin ./config//plugin/*.xml)
file(GLOB_RECURSE config ./config/node/*.json)
Expand All @@ -169,6 +170,7 @@ source_group_by_dir(proto)
source_group_by_dir(lua)
source_group_by_dir(plugin)
source_group_by_dir(config)
source_group_by_dir(pycli)

add_executable(${ProjectName} ${soruces} ${headers} ${proto} ${lua} ${plugin} ${config})

Expand Down
2 changes: 1 addition & 1 deletion config/plugin/backstage.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
<Plugin Name="core/net" />
<Plugin Name="core/log" />
<Plugin Name="core/node" />
<Plugin Name="node/backstage/logic" />
<Plugin Name="node/backstage/logic" HotReload="true" />
</Login>
</XML>
10 changes: 5 additions & 5 deletions config/plugin/db_proxy.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
<Plugin Name="core/net" />
<Plugin Name="core/log" />
<Plugin Name="core/node" />
<Plugin Name="node/db_proxy/mysql" />
<Plugin Name="node/db_proxy/mongo" />
<Plugin Name="node/db_proxy/redis" />
<Plugin Name="node/db_proxy/clickhouse" />
<Plugin Name="node/db_proxy/logic" />
<Plugin Name="node/db_proxy/mysql" HotReload="true" />
<Plugin Name="node/db_proxy/mongo" HotReload="true" />
<Plugin Name="node/db_proxy/redis" HotReload="true" />
<Plugin Name="node/db_proxy/clickhouse" HotReload="true"/>
<Plugin Name="node/db_proxy/logic" HotReload="true"/>
</DbProxy>
</XML>
2 changes: 1 addition & 1 deletion config/plugin/ds_mgr.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
<Plugin Name="core/net" />
<Plugin Name="core/log" />
<Plugin Name="core/node" />
<Plugin Name="node/ds_mgr/logic" />
<Plugin Name="node/ds_mgr/logic" HotReload="true"/>
</GameMgr>
</XML>
2 changes: 1 addition & 1 deletion config/plugin/game.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
<Plugin Name="core/net" />
<Plugin Name="core/log" />
<Plugin Name="core/node" />
<Plugin Name="node/game/logic" />
<Plugin Name="node/game/logic" HotReload="true"/>
</Game>
</XML>
2 changes: 1 addition & 1 deletion config/plugin/master.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
<Plugin Name="core/net" />
<Plugin Name="core/log" />
<Plugin Name="core/node" />
<Plugin Name="node/master/logic" />
<Plugin Name="node/master/logic" HotReload="true" />
</Master>
</XML>
2 changes: 1 addition & 1 deletion config/plugin/player.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
<Plugin Name="core/thread" />
<Plugin Name="core/lua" />
<Plugin Name="core/node" />
<Plugin Name="node/player/logic" />
<Plugin Name="node/player/logic" HotReload="true"/>
</Player>
</XML>
3 changes: 1 addition & 2 deletions config/plugin/proxy.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
<XML>
<Proxy>
<Plugin Name="core/net" />
<Plugin Name="core/config" />
<Plugin Name="core/log" />
<Plugin Name="core/utils" />
<Plugin Name="core/node" />

<Plugin Name="node/proxy/logic" />
<Plugin Name="node/proxy/logic" HotReload="true" />
</Proxy>
</XML>
2 changes: 1 addition & 1 deletion config/plugin/web.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<Plugin Name="core/net" />
<Plugin Name="core/log" />
<Plugin Name="core/node" />
<Plugin Name="node/web/logic" />
<Plugin Name="node/web/logic" HotReload="true"/>
</Login>

</XML>
2 changes: 1 addition & 1 deletion config/plugin/world.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
<Plugin Name="core/thread" />
<Plugin Name="core/lua" />
<Plugin Name="core/node" />
<Plugin Name="node/world/logic" />
<Plugin Name="node/world/logic" HotReload="true"/>
</World>
</XML>
18 changes: 14 additions & 4 deletions docker/build_image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,28 @@
cd $(dirname $0)
source ../tools/common.sh

build_type='docker'
version=$1
if [[ $version == "" ]];then
version="1.2"
fi

dockerfile=./docker/src
is_build_third_party=0
is_build_sqkctl=0
src_image_tag=pwnsky/squick_src:1.1
bin_image_tag=pwnsky/squick:1.1
src_image_tag=pwnsky/squick_src:$version
bin_image_tag=pwnsky/squick:$version
build_container=squick_src_build

cd $project_path

echo "Build src image"
docker build . -t $src_image_tag -f ./docker/src
docker build . -t $src_image_tag -f $dockerfile
check_err

echo "Export binary files"
docker run -d --name $build_container $src_image_tag
check_err
mkdir -p ./cache
rm -rf ./cache/docker_deploy
docker cp $build_container:/squick/deploy ./cache/docker_deploy
check_err
Expand All @@ -33,5 +39,9 @@ echo "Build release image"
docker build . -t $bin_image_tag -f ./docker/release
check_err

echo "Exporting the image"
docker save -o ./cache/squick_$version.tar pwnsky/squick:$version
check_err

echo "Build image ok"
print_ok
13 changes: 3 additions & 10 deletions docker/release
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
# cd {squick_project}
# docker build . -t i0gan/squick_src:1.1 -f ./docker/src
# docker run -d --name squick_src i0gan/squick_src:1.1
# rm -rf ./cache/docker_deploy
# docker cp squick_src:/squick/deploy ./cache/docker_deploy

# docker build . -t i0gan/squick:1.1 -f ./docker/release
# docker run -it --name squick i0gan/squick:1.1

FROM ubuntu:22.04

# Set env
ARG DEBIAN_FRONTEND=noninteractive
RUN apt update && apt install -y dos2unix vim net-tools

# copy from docker builded files
COPY ./cache/docker_deploy /squick
WORKDIR /squick
RUN chmod +x /squick/script/*.sh
CMD bash /squick/script/squick.sh
CMD bash /squick/script/squick.sh
18 changes: 18 additions & 0 deletions docker/release_mini
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# cd {squick_project}
# docker build . -t i0gan/squick_src:1.1 -f ./docker/src
# docker run -d --name squick_src i0gan/squick_src:1.1
# rm -rf ./cache/docker_deploy
# docker cp squick_src:/squick/deploy ./cache/docker_deploy

# docker build . -t i0gan/squick:1.1 -f ./docker/release
# docker run -it --name squick i0gan/squick:1.1

FROM ubuntu:22.04
# Set env
ARG DEBIAN_FRONTEND=noninteractive

# copy from docker builded files
COPY ./cache/docker_deploy /squick
WORKDIR /squick
RUN chmod +x /squick/script/*.sh
CMD bash /squick/script/squick.sh
15 changes: 15 additions & 0 deletions docker/src_dep
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM pwnsky/squick_src:1.1

COPY . /squick_dep

RUN rm -rf /squick_dep/third_party && mv /squick/third_party /squick_dep && rm -rf /squick && mv /squick_dep /squick

WORKDIR /squick
RUN cd tools && chmod +x *.sh && dos2unix *.sh
RUN cd script && chmod +x *.sh && dos2unix *.sh

RUN bash ./tools/clean_squick.sh
RUN bash ./tools/build_sqkctl.sh
RUN bash ./tools/build_squick.sh
RUN bash ./tools/generate_deploy.sh
CMD bash /squick/script/squick.sh
5 changes: 4 additions & 1 deletion kubernetes/gen_k8s_config.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#! /bin/bash

namespace="pwnsky"
image="pwnsky"
image="pwnsky/squick:1.1"

rm -rf k8s_cfg
mkdir -p k8s_cfg


39 changes: 39 additions & 0 deletions kubernetes/tmpl/backstage.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: backstage
namespace: default
labels:
app: squick
spec:
replicas: 1
selector:
matchLabels:
app: squick
template:
metadata:
labels:
app: squick
spec:
containers:
- name: squick
image: pwnsky/squick:1.2
imagePullPolicy: Never
command: ["/bin/bash", "-c"]
args:
- >
/squick/script/squick.sh type=backstage id=`expr 2500 + ${HOSTNAME##*-}` area=0 ip=$(POD_IP) port=10501 ws_port=10502 master_ip=svc-squick-master master_port=10001 logshow=0
env:
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: POD_IP
valueFrom:
fieldRef:
fieldPath: status.podIP
- name: POD_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
9 changes: 4 additions & 5 deletions kubernetes/node/master.yaml → kubernetes/tmpl/db_proxy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: squick-master
name: db-proxy
namespace: default
labels:
app: squick
spec:
serviceName: "svc-squick-master"
replicas: 2
replicas: 3
selector:
matchLabels:
app: squick
Expand All @@ -19,12 +18,12 @@ spec:
spec:
containers:
- name: squick
image: pwnsky/squick:1.1
image: pwnsky/squick:1.2
imagePullPolicy: Never
command: ["/bin/bash", "-c"]
args:
- >
/squick/script/squick.sh type=master id=1000${HOSTNAME##*-} area=0 ip=$(POD_IP) port=10001 http_port=50000 logshow=0
/squick/script/squick.sh type=proxy id=`expr 2000 + ${HOSTNAME##*-}` area=0 ip=$(POD_IP) port=10501 ws_port=10502 master_ip=svc-squick-master master_port=10001 logshow=0
env:
- name: POD_NAME
valueFrom:
Expand Down
53 changes: 53 additions & 0 deletions kubernetes/tmpl/master.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: squick-master
namespace: default
labels:
app: squick
spec:
serviceName: "svc-squick-master"
replicas: 3
selector:
matchLabels:
app: squick
template:
metadata:
labels:
app: squick
spec:
containers:
- name: squick
image: pwnsky/squick:1.2
imagePullPolicy: Never
command: ["/bin/bash", "-c"]
args:
- >
/squick/script/squick.sh type=master id=`expr 1 + ${HOSTNAME##*-}` area=0 ip=$(POD_IP) port=10001 http_port=50000 logshow=0
env:
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: POD_IP
valueFrom:
fieldRef:
fieldPath: status.podIP
- name: POD_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
---
apiVersion: v1
kind: Service
metadata:
name: svc-squick-master
spec:
selector:
app: squick
ports:
- protocol: TCP
port: 10001
targetPort: 10001
type: ClusterIP
40 changes: 40 additions & 0 deletions kubernetes/tmpl/player.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: squick-player
namespace: default
labels:
app: squick
spec:
#serviceName: "svc-squick-proxy"
replicas: 3
selector:
matchLabels:
app: squick
template:
metadata:
labels:
app: squick
spec:
containers:
- name: squick
image: pwnsky/squick:1.2
imagePullPolicy: Never
command: ["/bin/bash", "-c"]
args:
- >
/squick/script/squick.sh type=player id=`expr 1000 + ${HOSTNAME##*-}` area=0 ip=$(POD_IP) port=10401 master_ip=svc-squick-master master_port=10001 logshow=0
env:
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: POD_IP
valueFrom:
fieldRef:
fieldPath: status.podIP
- name: POD_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
Loading
Loading