Repository navigation
Expand file tree
/
Copy pathTaskfile.yml
More file actions
142 lines (113 loc) · 3.81 KB
/
Copy pathTaskfile.yml
File metadata and controls
142 lines (113 loc) · 3.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
version: '3'
################################################################################################
#
# ref:
# - https://taskfile.dev/#/styleguide
# - https://taskfile.dev/#/styleguide?id=use-the-correct-order-of-keywords
# - https://taskfile.dev/#/styleguide?id=use-colon-for-task-namespacing
# - yml format: https://juejin.cn/post/6844903972688363534
#
################################################################################################
env:
serverType:
configFile:
################################################################################################
tasks:
default:
cmds:
- task: init
- task: run
init:
cmds:
- task: init:db
tidy:
cmds:
- go mod tidy -v
#
# init db:
# - https://segmentfault.com/a/1190000020211225
# dump:
# - docker exec -it mysql mysqldump -u用户名 -p密码 数据库 > /mnt/vdb/data/mysql/test_db.sql
#
init:db:
cmds:
- docker exec -i mysql mysql --default-character-set=utf8mb4 -uroot -proot dev < ./proto/model/schema.sql
backup:db:
cmds:
- docker exec -it mysql mysqldump --no-data --default-character-set=utf8mb4 -R -E --hex-blob -uroot -proot dev > ./tmp/backup_schema.sql
backup:db:data:
cmds:
- docker exec -it mysql mysqldump --default-character-set=utf8mb4 -R -E --hex-blob -uroot -proot dev > ./tmp/backup.sql
################################################################################################
run:svc:
cmds:
- task: run:auto
vars:
{SERVER_TYPE: "inner", CONFIG_FILE: "configs/configs.yaml"}
run:api:
cmds:
- task: run:auto
vars:
{SERVER_TYPE: "outer", CONFIG_FILE: "configs/configs.yaml"}
run:job:
cmds:
- task: run:auto
vars:
{SERVER_TYPE: "job", CONFIG_FILE: "configs/configs.yaml"}
run:admin:
cmds:
- task: run:auto
vars:
{SERVER_TYPE: "admin", CONFIG_FILE: "configs/configs.yaml"}
################################################################################################
run:auto:
cmds:
- export serverType={{.SERVER_TYPE}}; export configFile={{.CONFIG_FILE}}; air -d # 自动watch 代码变更, 热加载:
run:debug:
cmds:
- go run cmd/main.go -f configs/configs.yaml
build:
cmds:
- go build -o ./tmp/main ./cmd
# - ./tmp/main --configFile=configs/configs.yaml --serverType=inner # 命令行传参方式1
# - SERVER_TYPE=inner CONFIG_FILE=configs/configs.yaml ./tmp/main # 命令行传参方式2
################################################################################################
test:pub:msg:
cmds:
- |
curl --request POST \
--url http://localhost:8000/queue/publish/ \
--header 'content-type: application/json' \
--data '{"queue_name": "test-queue", "type": "type1", "data": "test messagexxxx6", "raw_data": 1, "timestamp": 2}'
# API 测试:
test:api:
cmds:
- curl -i http://localhost:8000/hello/tom
- curl -i http://localhost:8000/hello/jim
test:api:graphql:
cmds:
- curl -i http://localhost:8000/graphql/do
proto:gen:
cmds:
- |
find ./ -iname "*.proto" -exec \
protoc --proto_path=. \
--proto_path=../../../pkg/x \
--go_out=paths=source_relative:. \
--go-http_out=paths=source_relative:. \
--go-grpc_out=paths=source_relative:. \
--openapi_out==paths=source_relative:. \
{} \;
- go generate ./...
#
# under mac osx: kill 进程:
#
kill:
cmds:
- lsof -ti :6000 | xargs kill # rpc server
- lsof -ti :8000 | xargs kill # api server
- lsof -ti :8001 | xargs kill # admin api
- lsof -ti :8002 | xargs kill # job server
clean:
cmds:
- task: kill