正在显示
10 个修改的文件
包含
420 行增加
和
0 行删除
.gitignore
0 → 100644
1 | +# Binaries for programs and plugins | ||
2 | +*.exe | ||
3 | +*.dll | ||
4 | +*.so | ||
5 | +*.dylib | ||
6 | +*.vscode | ||
7 | + | ||
8 | +# Test binary, build with `go test -c` | ||
9 | +*.test | ||
10 | + | ||
11 | +# Output of the go coverage tool, specifically when used with LiteIDE | ||
12 | +*.out | ||
13 | + | ||
14 | +*.log | ||
15 | +*debug | ||
16 | +*wasm | ||
17 | + | ||
18 | +*.idea | ||
19 | + | ||
20 | +*.tmp | ||
21 | + | ||
22 | +*.sum | ||
23 | + | ||
24 | +opp | ||
25 | +/vendor | ||
26 | +/*.exe~ |
Dockerfile
0 → 100644
1 | +FROM golang:1.13 as builder | ||
2 | +ENV GOPROXY https://goproxy.cn | ||
3 | +ENV GO111MODULE on | ||
4 | +ENV GOPATH /go | ||
5 | +RUN git clone http://gitlab.fjmaimaimai.com/mmm-go/gocomm.git /go/src/gocomm \ | ||
6 | + && cd /go/src/gocomm \ | ||
7 | + && git pull | ||
8 | +WORKDIR /go/src/opp-building | ||
9 | + | ||
10 | +COPY go.mod . | ||
11 | + | ||
12 | +COPY . . | ||
13 | +RUN GOOS=linux CGO_ENABLED=0 go build -ldflags="-s -w" -o opp-building main.go | ||
14 | + | ||
15 | +EXPOSE 8080 | ||
16 | +CMD ["./opp-building"] |
deploy/k8s/dev/install.sh
0 → 100644
1 | +#!/bin/bash | ||
2 | +export PATH=/root/local/bin:$PATH | ||
3 | +kubectl -n mmm-suplus-dev get pods | grep -q mmmopp-building | ||
4 | +if [ "$?" == "1" ];then | ||
5 | + kubectl create -f /tmp/dev/mmm-go-opp/opp.yaml --record | ||
6 | + kubectl -n mmm-suplus-dev get svc | grep -q mmmopp-building | ||
7 | + if [ "$?" == "0" ];then | ||
8 | + echo "mmmopp-building service install success!" | ||
9 | + else | ||
10 | + echo "mmmopp-building service install fail!" | ||
11 | + fi | ||
12 | + kubectl -n mmm-suplus-dev get pods | grep -q mmmopp-building | ||
13 | + if [ "$?" == "0" ];then | ||
14 | + echo "mmmopp-building deployment install success!" | ||
15 | + else | ||
16 | + echo "mmmopp-building deployment install fail!" | ||
17 | + fi | ||
18 | +else | ||
19 | + kubectl delete -f /tmp/dev/mmm-go-opp/opp.yaml | ||
20 | + kubectl -n mmm-suplus-dev get svc | grep -q mmmopp-building | ||
21 | + while [ "$?" == "0" ] | ||
22 | + do | ||
23 | + kubectl -n mmm-suplus-dev get svc | grep -q mmmopp-building | ||
24 | + done | ||
25 | + kubectl -n mmm-suplus-dev get pods | grep -q mmmopp-building | ||
26 | + while [ "$?" == "0" ] | ||
27 | + do | ||
28 | + kubectl -n mmm-suplus-dev get pods | grep -q mmmopp-building | ||
29 | + done | ||
30 | + kubectl create -f /tmp/dev/mmm-go-opp/opp.yaml --record | ||
31 | + kubectl -n mmm-suplus-dev get svc | grep -q mmmopp-building | ||
32 | + if [ "$?" == "0" ];then | ||
33 | + echo "mmmopp-building service update success!" | ||
34 | + else | ||
35 | + echo "opp service update fail!" | ||
36 | + fi | ||
37 | + kubectl -n mmm-suplus-dev get pods | grep -q opp | ||
38 | + if [ "$?" == "0" ];then | ||
39 | + echo "opp deployment update success!" | ||
40 | + else | ||
41 | + echo "opp deployment update fail!" | ||
42 | + fi | ||
43 | +fi |
deploy/k8s/dev/opp.yaml
0 → 100644
1 | +apiVersion: v1 | ||
2 | +kind: Service | ||
3 | +metadata: | ||
4 | + name: mmmopp-building | ||
5 | + namespace: mmm-suplus-dev | ||
6 | + labels: | ||
7 | + k8s-app: mmmopp-building | ||
8 | +spec: | ||
9 | + ports: | ||
10 | + - name: "http" | ||
11 | + port: 80 | ||
12 | + targetPort: 8080 | ||
13 | + selector: | ||
14 | + k8s-app: mmmopp-building | ||
15 | +--- | ||
16 | +apiVersion: extensions/v1beta1 | ||
17 | +kind: Deployment | ||
18 | +metadata: | ||
19 | + name: mmmopp-building | ||
20 | + namespace: mmm-suplus-dev | ||
21 | + labels: | ||
22 | + k8s-app: mmmopp-building | ||
23 | +spec: | ||
24 | + replicas: 1 | ||
25 | + template: | ||
26 | + metadata: | ||
27 | + labels: | ||
28 | + k8s-app: mmmopp-building | ||
29 | + spec: | ||
30 | + affinity: | ||
31 | + nodeAffinity: | ||
32 | + preferredDuringSchedulingIgnoredDuringExecution: | ||
33 | + - preference: {} | ||
34 | + weight: 100 | ||
35 | + requiredDuringSchedulingIgnoredDuringExecution: | ||
36 | + nodeSelectorTerms: | ||
37 | + - matchExpressions: | ||
38 | + - key: kubernetes.io/hostname | ||
39 | + operator: In | ||
40 | + values: | ||
41 | + - cn-hangzhou.i-bp1djh1xn7taumbue1ze | ||
42 | + - cn-hangzhou.i-bp1djh1xn7taumbue1zd | ||
43 | + - cn-hangzhou.i-bp1euf5u1ph9kbhtndhb | ||
44 | + - cn-hangzhou.i-bp1hyp5oips9cdwxxgxy | ||
45 | + containers: | ||
46 | + - name: mmmopp-building | ||
47 | + image: 192.168.0.243:5000/mmm/mmmopp-building:dev | ||
48 | + imagePullPolicy: Always | ||
49 | + volumeMounts: | ||
50 | + - mountPath: /opt/logs | ||
51 | + name: accesslogs | ||
52 | + - mountPath: /var/www/opp/file | ||
53 | + name: mmmjihuitest-pvc1 | ||
54 | + ports: | ||
55 | + - containerPort: 8080 | ||
56 | + env: | ||
57 | + - name: MYSQL_HOST | ||
58 | + valueFrom: | ||
59 | + configMapKeyRef: | ||
60 | + name: suplus-config | ||
61 | + key: mysql.host | ||
62 | + - name: MYSQL_PORT | ||
63 | + valueFrom: | ||
64 | + configMapKeyRef: | ||
65 | + name: suplus-config | ||
66 | + key: mysql.port | ||
67 | + volumes: | ||
68 | + - name: accesslogs | ||
69 | + emptyDir: {} | ||
70 | + - name: mmmjihuitest-pvc1 | ||
71 | + persistentVolumeClaim: | ||
72 | + claimName: mmmjihuitest-pvc |
deploy/k8s/prd/install.sh
0 → 100644
1 | +#!/bin/bash | ||
2 | +export PATH=/root/local/bin:$PATH | ||
3 | +kubectl -n mmm-suplus-prd get pods | grep -q mmmopp-building | ||
4 | +if [ "$?" == "1" ];then | ||
5 | + kubectl create -f /tmp/prd/mmm-go-opp/opp.yaml --record | ||
6 | + kubectl -n mmm-suplus-prd get svc | grep -q mmmopp-building | ||
7 | + if [ "$?" == "0" ];then | ||
8 | + echo "mmmopp-building service install success!" | ||
9 | + else | ||
10 | + echo "mmmopp-building service install fail!" | ||
11 | + fi | ||
12 | + kubectl -n mmm-suplus-prd get pods | grep -q mmmopp-building | ||
13 | + if [ "$?" == "0" ];then | ||
14 | + echo "mmmopp-building deployment install success!" | ||
15 | + else | ||
16 | + echo "mmmopp-building deployment install fail!" | ||
17 | + fi | ||
18 | +else | ||
19 | + kubectl delete -f /tmp/prd/mmm-go-opp/opp.yaml | ||
20 | + kubectl -n mmm-suplus-prd get svc | grep -q mmmopp-building | ||
21 | + while [ "$?" == "0" ] | ||
22 | + do | ||
23 | + kubectl -n mmm-suplus-prd get svc | grep -q mmmopp-building | ||
24 | + done | ||
25 | + kubectl -n mmm-suplus-prd get pods | grep -q mmmopp-building | ||
26 | + while [ "$?" == "0" ] | ||
27 | + do | ||
28 | + kubectl -n mmm-suplus-prd get pods | grep -q mmmopp-building | ||
29 | + done | ||
30 | + kubectl create -f /tmp/prd/mmm-go-opp/opp.yaml --record | ||
31 | + kubectl -n mmm-suplus-prd get svc | grep -q mmmopp-building | ||
32 | + if [ "$?" == "0" ];then | ||
33 | + echo "mmmopp-building service update success!" | ||
34 | + else | ||
35 | + echo "opp service update fail!" | ||
36 | + fi | ||
37 | + kubectl -n mmm-suplus-prd get pods | grep -q opp | ||
38 | + if [ "$?" == "0" ];then | ||
39 | + echo "opp deployment update success!" | ||
40 | + else | ||
41 | + echo "opp deployment update fail!" | ||
42 | + fi | ||
43 | +fi |
deploy/k8s/prd/opp.yaml
0 → 100644
1 | +apiVersion: v1 | ||
2 | +kind: Service | ||
3 | +metadata: | ||
4 | + name: mmmopp-building | ||
5 | + namespace: mmm-suplus-prd | ||
6 | + labels: | ||
7 | + k8s-app: mmmopp-building | ||
8 | +spec: | ||
9 | + ports: | ||
10 | + - name: "http" | ||
11 | + port: 80 | ||
12 | + targetPort: 8080 | ||
13 | + selector: | ||
14 | + k8s-app: mmmopp-building | ||
15 | +--- | ||
16 | +apiVersion: extensions/v1beta1 | ||
17 | +kind: Deployment | ||
18 | +metadata: | ||
19 | + name: mmmopp-building | ||
20 | + namespace: mmm-suplus-prd | ||
21 | + labels: | ||
22 | + k8s-app: mmmopp-building | ||
23 | +spec: | ||
24 | + replicas: 1 | ||
25 | + template: | ||
26 | + metadata: | ||
27 | + labels: | ||
28 | + k8s-app: mmmopp-building | ||
29 | + spec: | ||
30 | + affinity: | ||
31 | + nodeAffinity: | ||
32 | + preferredDuringSchedulingIgnoredDuringExecution: | ||
33 | + - preference: {} | ||
34 | + weight: 100 | ||
35 | + requiredDuringSchedulingIgnoredDuringExecution: | ||
36 | + nodeSelectorTerms: | ||
37 | + - matchExpressions: | ||
38 | + - key: kubernetes.io/hostname | ||
39 | + operator: In | ||
40 | + values: | ||
41 | + - cn-hangzhou.i-bp1djh1xn7taumbue1ze | ||
42 | + - cn-hangzhou.i-bp1djh1xn7taumbue1zd | ||
43 | + - cn-hangzhou.i-bp1euf5u1ph9kbhtndhb | ||
44 | + - cn-hangzhou.i-bp1hyp5oips9cdwxxgxy | ||
45 | + containers: | ||
46 | + - name: mmmopp-building | ||
47 | + image: 192.168.0.243:5000/mmm/mmmopp-building:master | ||
48 | + imagePullPolicy: Always | ||
49 | + volumeMounts: | ||
50 | + - mountPath: /opt/logs | ||
51 | + name: accesslogs | ||
52 | + - mountPath: /var/www/opp/file | ||
53 | + name: opportunity-pvc1 | ||
54 | + ports: | ||
55 | + - containerPort: 8080 | ||
56 | + env: | ||
57 | + - name: MYSQL_HOST | ||
58 | + valueFrom: | ||
59 | + configMapKeyRef: | ||
60 | + name: suplus-config | ||
61 | + key: mysql.host | ||
62 | + - name: MYSQL_PORT | ||
63 | + valueFrom: | ||
64 | + configMapKeyRef: | ||
65 | + name: suplus-config | ||
66 | + key: mysql.port | ||
67 | + volumes: | ||
68 | + - name: accesslogs | ||
69 | + emptyDir: {} | ||
70 | + - name: opportunity-pvc1 | ||
71 | + persistentVolumeClaim: | ||
72 | + claimName: opportunity-pvc5 |
deploy/k8s/test/install.sh
0 → 100644
1 | +#!/bin/bash | ||
2 | +export PATH=/root/local/bin:$PATH | ||
3 | +kubectl -n mmm-suplus-test get pods | grep -q mmmopp-building | ||
4 | +if [ "$?" == "1" ];then | ||
5 | + kubectl create -f /tmp/test/mmm-go-opp/opp.yaml --record | ||
6 | + kubectl -n mmm-suplus-test get svc | grep -q mmmopp-building | ||
7 | + if [ "$?" == "0" ];then | ||
8 | + echo "mmmopp-building service install success!" | ||
9 | + else | ||
10 | + echo "mmmopp-building service install fail!" | ||
11 | + fi | ||
12 | + kubectl -n mmm-suplus-test get pods | grep -q mmmopp-building | ||
13 | + if [ "$?" == "0" ];then | ||
14 | + echo "mmmopp-building deployment install success!" | ||
15 | + else | ||
16 | + echo "mmmopp-building deployment install fail!" | ||
17 | + fi | ||
18 | +else | ||
19 | + kubectl delete -f /tmp/test/mmm-go-opp/opp.yaml | ||
20 | + kubectl -n mmm-suplus-test get svc | grep -q mmmopp-building | ||
21 | + while [ "$?" == "0" ] | ||
22 | + do | ||
23 | + kubectl -n mmm-suplus-test get svc | grep -q mmmopp-building | ||
24 | + done | ||
25 | + kubectl -n mmm-suplus-test get pods | grep -q mmmopp-building | ||
26 | + while [ "$?" == "0" ] | ||
27 | + do | ||
28 | + kubectl -n mmm-suplus-test get pods | grep -q mmmopp-building | ||
29 | + done | ||
30 | + kubectl create -f /tmp/test/mmm-go-opp/opp.yaml --record | ||
31 | + kubectl -n mmm-suplus-test get svc | grep -q mmmopp-building | ||
32 | + if [ "$?" == "0" ];then | ||
33 | + echo "mmmopp-building service update success!" | ||
34 | + else | ||
35 | + echo "opp service update fail!" | ||
36 | + fi | ||
37 | + kubectl -n mmm-suplus-test get pods | grep -q opp | ||
38 | + if [ "$?" == "0" ];then | ||
39 | + echo "opp deployment update success!" | ||
40 | + else | ||
41 | + echo "opp deployment update fail!" | ||
42 | + fi | ||
43 | +fi |
deploy/k8s/test/opp.yaml
0 → 100644
1 | +apiVersion: v1 | ||
2 | +kind: Service | ||
3 | +metadata: | ||
4 | + name: mmmopp-building | ||
5 | + namespace: mmm-suplus-test | ||
6 | + labels: | ||
7 | + k8s-app: mmmopp-building | ||
8 | +spec: | ||
9 | + ports: | ||
10 | + - name: "http" | ||
11 | + port: 80 | ||
12 | + targetPort: 8080 | ||
13 | + selector: | ||
14 | + k8s-app: mmmopp-building | ||
15 | +--- | ||
16 | +apiVersion: extensions/v1beta1 | ||
17 | +kind: Deployment | ||
18 | +metadata: | ||
19 | + name: mmmopp-building | ||
20 | + namespace: mmm-suplus-test | ||
21 | + labels: | ||
22 | + k8s-app: mmmopp-building | ||
23 | +spec: | ||
24 | + replicas: 1 | ||
25 | + template: | ||
26 | + metadata: | ||
27 | + labels: | ||
28 | + k8s-app: mmmopp-building | ||
29 | + spec: | ||
30 | + affinity: | ||
31 | + nodeAffinity: | ||
32 | + preferredDuringSchedulingIgnoredDuringExecution: | ||
33 | + - preference: {} | ||
34 | + weight: 100 | ||
35 | + requiredDuringSchedulingIgnoredDuringExecution: | ||
36 | + nodeSelectorTerms: | ||
37 | + - matchExpressions: | ||
38 | + - key: kubernetes.io/hostname | ||
39 | + operator: In | ||
40 | + values: | ||
41 | + - cn-hangzhou.i-bp1djh1xn7taumbue1ze | ||
42 | + - cn-hangzhou.i-bp1djh1xn7taumbue1zd | ||
43 | + - cn-hangzhou.i-bp1euf5u1ph9kbhtndhb | ||
44 | + - cn-hangzhou.i-bp1hyp5oips9cdwxxgxy | ||
45 | + containers: | ||
46 | + - name: mmmopp-building | ||
47 | + image: 192.168.0.243:5000/mmm/mmmopp-building:dev | ||
48 | + imagePullPolicy: Always | ||
49 | + volumeMounts: | ||
50 | + - mountPath: /opt/logs | ||
51 | + name: accesslogs | ||
52 | + - mountPath: /var/www/opp/file | ||
53 | + name: mmmjihuitest2-pvc1 | ||
54 | + ports: | ||
55 | + - containerPort: 8080 | ||
56 | + volumes: | ||
57 | + - name: accesslogs | ||
58 | + emptyDir: {} | ||
59 | + - name: mmmjihuitest2-pvc1 | ||
60 | + persistentVolumeClaim: | ||
61 | + claimName: mmmjihuitest2-pvc |
go.mod
0 → 100644
1 | +module opp | ||
2 | + | ||
3 | +go 1.12 | ||
4 | + | ||
5 | +require ( | ||
6 | + github.com/aliyun/alibaba-cloud-sdk-go v1.60.348 | ||
7 | + github.com/astaxie/beego v1.10.0 | ||
8 | + github.com/disintegration/imaging v1.6.2 | ||
9 | + github.com/go-sql-driver/mysql v1.4.1 | ||
10 | + github.com/gomodule/redigo v1.7.0 | ||
11 | + github.com/gorilla/websocket v1.4.1 | ||
12 | + github.com/klauspost/cpuid v1.2.1 // indirect | ||
13 | + github.com/prometheus/client_golang v1.1.0 | ||
14 | + github.com/prometheus/common v0.6.0 | ||
15 | + github.com/satori/go.uuid v1.2.0 | ||
16 | + github.com/sony/sonyflake v1.0.0 | ||
17 | + gitlab.fjmaimaimai.com/mmm-go/gocomm v0.0.1 | ||
18 | + google.golang.org/appengine v1.6.2 // indirect | ||
19 | +) | ||
20 | + | ||
21 | +replace gitlab.fjmaimaimai.com/mmm-go/gocomm => ../gocomm |
main.go
0 → 100644
1 | +package main | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "os" | ||
6 | + "os/signal" | ||
7 | + "syscall" | ||
8 | +) | ||
9 | + | ||
10 | +func main() { | ||
11 | + sigs := make(chan os.Signal, 0) | ||
12 | + exit := make(chan bool, 1) | ||
13 | + signal.Notify(sigs, syscall.SIGINT, syscall.SIGKILL) | ||
14 | + fmt.Println("begin ...") | ||
15 | + go func() { | ||
16 | + sig := <-sigs | ||
17 | + fmt.Println("notify:", sig) | ||
18 | + exit <- true | ||
19 | + }() | ||
20 | + fmt.Println("awaiting signal") | ||
21 | + <-exit | ||
22 | + fmt.Println("exiting") | ||
23 | +} |
-
请 注册 或 登录 后发表评论