-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
73 lines (57 loc) · 1.44 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
PROJECT_ROOT:=/home/isucon/isuumo
BUILD_DIR:=/home/isucon/isuumo/webapp/go
BIN_NAME:=isuumo
BIN_PATH:=/home/isucon/isuumo/webapp/go/isuumo
SERVICE_NAME:=isuumo.go
APP_LOCAL_URL:=http://localhost:1323
NGX_SERVICE=nginx
NGX_LOG:=/var/log/nginx/access.log
MYSQL_SERVICE=mysql
MYSQL_LOG:=/var/log/mysql/mysql.log
HOSTNAME:=$(shell hostname)
BRANCH:=master
all: build
.PHONY: clean
clean:
cd $(BUILD_DIR); \
rm -rf ${BIN_NAME}
.PHONY: deploy
deploy: before build config-files start
.PHONY: deploy-nolog
deploy-nolog: before build-nolog config-files start
.PHONY: checkout
checkout:
git fetch && \
git reset --hard origin/$(BRANCH)
.PHONY: build
build: checkout
cd $(BUILD_DIR); \
go build -o isuumo
# TODO
.PHONY: build-nolog
build-nolog: checkout
cd $(BUILD_DIR); \
go build -tags release -o isuumo
# TODO
.PHONY: config-files
config-files:
sudo rsync -v -r $(HOSTNAME)/ /
.PHONY: start
start:
sh $(HOSTNAME)/deploy.sh
.PHONY: pprof
pprof:
pprof -png -output /tmp/pprof.png $(BIN_PATH) $(APP_LOCAL_URL)/debug/pprof/profile
# slackcat /tmp/pprof.png
pprof -http=0.0.0.0:9090 $(BIN_PATH) `ls -lt $(HOME)/pprof/* | head -n 1 | gawk '{print $$9}'`
.PHONY: kataru
kataru:
sudo cat $(NGX_LOG) | kataribe -f /etc/kataribe.toml | slackcat
.PHONY: before
before:
$(eval when := $(shell date "+%s"))
mkdir -p ~/logs/$(when)
sudo touch $(NGX_LOG)
sudo touch $(MYSQL_LOG)
sudo mv -f $(NGX_LOG) ~/logs/$(when)/
sudo mv -f $(MYSQL_LOG) ~/logs/$(when)/