-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
70 lines (47 loc) · 1.54 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
BINARY=bin/monitoring-system.out
CMD_DIR=./src/cmd
CONFIG_DIR=./src/config
INTERNAL_DIR=./src/internal
PKG_DIR=./src/pkg
WEB_DIR=./src/web
BIN_INSTALL_DIR=/usr/bin/monitoring-system
GOOS?=$(shell go env GOOS)
GOARCH?=$(shell go env GOARCH)
GO=go
GOFMT=gofmt
PKGS=$(shell $(GO) list ./... | grep -v /vendor/)
all: build
build:
$(GO) build -o $(BINARY) $(CMD_DIR)/main.go
run: build
$(BINARY)
test:
$(GO) test -v $(PKGS)
clean:
$(GO) clean
rm -f $(BINARY)
deps:
$(GO) get -u ./...
deploy: build deploy-config
sudo mkdir -p $(BIN_INSTALL_DIR) $(BIN_INSTALL_DIR)/web /usr/share/monitoring-system
sudo cp $(BINARY) $(BIN_INSTALL_DIR)
sudo chmod +x $(BIN_INSTALL_DIR)/monitoring-system.out
sudo cp -r $(WEB_DIR)/* $(BIN_INSTALL_DIR)/web
sudo cp monitoring-system.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable monitoring-system.service
sudo systemctl restart monitoring-system.service
deploy-config:
@sudo mkdir -p /etc/monitoring-system
@JWT_KEY=$$(openssl rand -hex 32); \
sudo sed "s/SET_ME/$${JWT_KEY}/g" ./config.yaml.template | sudo tee /etc/monitoring-system/config.yaml > /dev/null
.PHONY: all build run test clean deps deploy deploy-config
remove-deploy:
sudo systemctl stop monitoring-system.service || true
sudo systemctl disable monitoring-system.service || true
sudo systemctl daemon-reload
sudo rm -rf $(BIN_INSTALL_DIR)
sudo rm -rf /etc/monitoring-system /usr/share/monitoring-system
sudo rm -f /etc/systemd/system/monitoring-system.service
sudo systemctl daemon-reload
.PHONY: remove-deploy