-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
50 lines (37 loc) · 1.02 KB
/
Makefile
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
# Go parameters
OS_MACH=$(shell uname -s; uname -m)
BINARY_NAME=quicklog
ifeq ($(OS_MACH),Linux x86_64)
BINARY_LINUX=$(BINARY_NAME)
else
BINARY_LINUX=$(BINARY_NAME)-linux
endif
BINARY_DARWIN=$(BINARY_NAME)-darwin
all: test build
rebuild: delete-binary build
rebuild-linux: delete-binary-linux build-linux
delete-binary:
-rm $(BINARY_NAME) 2>/dev/null
delete-binary-linux:
-rm $(BINARY_LINUX) 2>/dev/null
build: deps
go build -o $(BINARY_NAME) -v
build-linux:
CGO_ENABLED= GOOS=linux GOARCH=amd64 go build -o $(BINARY_LINUX) -v
build-darwin:
CGO_ENABLED= GOOS=darwin GOARCH=amd64 go build -o $(BINARY_DARWIN) -v
test:
go test -v ./...
clean:
go clean
rm -f $(BINARY_NAME)
rm -f $(BINARY_LINUX)
deploy-prod: build-linux
ssh prod "mv /opt/quicklog/$(BINARY_NAME) /opt/quicklog/$(BINARY_NAME)-old || true"
scp $(BINARY_LINUX) prod:/opt/quicklog/$(BINARY_NAME)
ssh prod "sudo service quicklog restart"
run: deps
go run -race main.go
deps:
go get github.com/go-sql-driver/mysql
go get github.com/kuangchanglang/graceful