This commit is contained in:
meixiongfeng 2022-07-07 11:44:09 +08:00
commit 849e501842
10 changed files with 1605 additions and 7 deletions

View File

@ -0,0 +1,68 @@
version: '3.7'
# 申明同一个网络
networks:
net:
name: net
# 游戏数据卷
volumes:
consuldata:
name: consuldata
redisdata:
name: redisdata
mongodata:
name: mongodata
# 服务
services:
redis:
image: redis:latest
container_name: redis
ports:
- '10011:6379'
networks:
net:
# 给网络取别名,可以用redis和cache找到
aliases:
- cache
command: /etc/redis/redis.conf
volumes:
# 持久存储redis的数据
- redisdata:/data
# 挂载本地配置文件
- ./redis.conf:/etc/redis/redis.conf
# 时间同步
# - /etc/localtime:/etc/localtime
consul:
image: consul:latest
container_name: consul
ports:
- '10012:8500'
command: consul agent -server -bootstrap -data-dir /consul/data -node=ylconsul -bind=0.0.0.0 -config-dir=/consul/config/ -client=0.0.0.0 -ui
networks:
net:
# 给网络取别名,可以用consul和discovery找到
aliases:
- discovery
volumes:
- consuldata:/consul/data
mongo:
image: mongo:latest
container_name: mongo
ports:
- '10013:27017'
networks:
net:
# 给网络取别名,可以用mongodb和db找到
aliases:
- db
command: ['mongod', '-f', '/etc/mongo/mongod.conf']
# environment:
# MONGO_INITDB_ROOT_USERNAME: liwei1dao
# MONGO_INITDB_ROOT_PASSWORD: li13451234
volumes:
# 持久存储mongodb的数据
- mongodata:/data/db:rw
- mongodata:/data/configdb:rw
# 挂载本地配置文件
- ./mongod.conf:/etc/mongo/mongod.conf:rw

View File

@ -0,0 +1,48 @@
# mongod.conf
# for documentation of all options, see:
# http://docs.mongodb.org/manual/reference/configuration-options/
# where to write logging data.
# systemLog:
# destination: file
# logAppend: true
# path: "/var/log/mongodb/mongod.log"
# Where and how to store data.
storage:
dbPath: /data/db
journal:
enabled: true
wiredTiger:
engineConfig:
cacheSizeGB: 0.256
# engine:
# mmapv1:
# wiredTiger:
# how the process runs
# processManagement:
# fork: false # fork and run in background
# pidFilePath: /var/run/mongodb/mongod.pid # location of pidfile
# timeZoneInfo: /usr/share/zoneinfo
# network interfaces
net:
port: 27017
bindIp: 0.0.0.0 # Enter 0.0.0.0,:: to bind to all IPv4 and IPv6 addresses or, alternatively, use the net.bindIpAll setting.
#security:
#operationProfiling:
#replication:
#sharding:
## Enterprise-Only Options
#auditLog:
#snmp:

View File

@ -0,0 +1,37 @@
# Client port of 4222 on all interfaces
port: 4222
# HTTP monitoring port
monitor_port: 8222
# This is for clustering multiple servers together.
cluster {
# Route connections to be received on any interface on port 6222
port: 6222
# Routes are protected, so need to use them with --routes flag
# e.g. --routes=nats-route://ruser:T0pS3cr3t@otherdockerhost:6222
# authorization {
# user: ruser
# password: T0pS3cr3t
# timeout: 0.75
# }
# Routes are actively solicited and connected to from this server.
# This Docker image has none by default, but you can pass a
# flag to the nats-server docker image to create one to an existing server.
routes = []
}
# max_connections
max_connections: 100
# max_subscriptions (per connection)
max_subscriptions: 1000
# maximum protocol control line
max_control_line: 512
# maximum payload
max_payload: 65536

View File

@ -0,0 +1,63 @@
user nginx;
worker_processes 2;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 4096;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 120;
#gzip on;
include /etc/nginx/conf.d/*.conf;
#(配置请求体缓存区大小, 不配的话)
}
stream {
# redisd 代理
upstream redis {
hash $remote_addr consistent;
server redis:6379 weight=5 max_fails=1 fail_timeout=10s;
}
server {
listen 10001;
proxy_pass redis;
}
# redisd 代理
upstream mongo {
hash $remote_addr consistent;
server mongo:27017 weight=5 max_fails=1 fail_timeout=10s;
}
server {
listen 10002;
proxy_pass mongo;
}
# consul 代理
upstream consul {
hash $remote_addr consistent;
server consul:8500 weight=5 max_fails=1 fail_timeout=10s;
}
server {
listen 10003;
proxy_pass consul;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -8,7 +8,6 @@ import (
"go_dreamfactory/lego/base"
"go_dreamfactory/lego/core"
"go_dreamfactory/lego/core/cbase"
"go_dreamfactory/lego/sys/cron"
"go_dreamfactory/lego/sys/event"
"go_dreamfactory/lego/sys/log"
"go_dreamfactory/lego/sys/rpcx"
@ -116,7 +115,6 @@ func (this *RPCXService) Destroy() (err error) {
if err = rpcx.Stop(); err != nil {
return
}
cron.Stop()
err = this.ServiceBase.Destroy()
return
}

View File

@ -62,7 +62,7 @@ type Service struct {
func (this *Service) Start() (err error) {
go func() {
if err = this.server.Serve("tcp", this.options.ServiceAddr); err != nil {
this.Errorf("rpcx server exit!")
this.Warnf("rpcx server exit:%v", err)
}
}()
return

6
linux_bulid.sh Normal file
View File

@ -0,0 +1,6 @@
CGO_ENABLED=0
GO111MODULE=on
GOOS=linux
go build -o ./bin/dbservice ./services/dbservice/main.go
go build -o ./bin/gateway ./services/gateway/main.go
go build -o ./bin/worker ./services/worker/main.go

View File

@ -8,6 +8,7 @@ import (
"go_dreamfactory/modules/hero"
"go_dreamfactory/modules/items"
"go_dreamfactory/modules/mail"
"go_dreamfactory/modules/shop"
"go_dreamfactory/modules/story"
"go_dreamfactory/modules/task"
"go_dreamfactory/modules/user"
@ -48,6 +49,7 @@ func main() {
equipment.NewModule(),
task.NewModule(),
story.NewModule(),
shop.NewModule(),
)
}

View File

@ -4,13 +4,11 @@ import (
"fmt"
"go_dreamfactory/utils"
"testing"
"time"
)
func TestIsToday(t *testing.T) {
tt := time.Unix(1657163870, 0)
fmt.Println(utils.IsToday(tt))
// tt := time.Unix(1657163870, 0)
// fmt.Println(utils.IsToday(tt))
}
func TestSubTime(t *testing.T) {