-
Notifications
You must be signed in to change notification settings - Fork 228
/
Makefile
252 lines (210 loc) · 8.5 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
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
NAME=faktory
VERSION=1.9.1
# when fixing packaging bugs but not changing the binary, we increment ITERATION
ITERATION=1
BASENAME=$(NAME)_$(VERSION)-$(ITERATION)
TEST_FLAGS=-parallel 4
ifdef DETECT_RACES
TEST_FLAGS += -race
endif
# TODO I'd love some help making this a proper Makefile
# with real file dependencies.
.DEFAULT_GOAL := help
all: test
# need to login with `mperham` and the personal token at github.com/settings/tokens
release:
cp /tmp/faktory-ent_$(VERSION).macos.* packaging/output/systemd
@echo Generating release notes
ruby .github/notes.rb $(VERSION)
@echo Releasing $(NAME) $(VERSION)
hub release create v$(VERSION) \
-a packaging/output/systemd/faktory_$(VERSION)-$(ITERATION)_amd64.deb \
-a packaging/output/systemd/faktory_$(VERSION)-$(ITERATION)_arm64.deb \
-a packaging/output/systemd/faktory-$(VERSION)-$(ITERATION).x86_64.rpm \
-a packaging/output/systemd/faktory-$(VERSION)-$(ITERATION).aarch64.rpm \
-a packaging/output/systemd/faktory-ent_$(VERSION).macos.arm64.tbz \
-a packaging/output/systemd/faktory-ent_$(VERSION).macos.amd64.tbz \
-F /tmp/release-notes.md -e -o || :
prepare: ## install build prereqs
go install github.com/benbjohnson/ego/...@v0.4.3
@echo Now you should be ready to run "make"
tags: clean ## Create tags file for vim, etc
find . -name "*.go" | grep -v "./vendor" | gotags -L - > tags
test: clean generate ## Execute test suite
go test $(TEST_FLAGS) \
github.com/contribsys/faktory/client \
github.com/contribsys/faktory/cli \
github.com/contribsys/faktory/manager \
github.com/contribsys/faktory/server \
github.com/contribsys/faktory/storage \
github.com/contribsys/faktory/test \
github.com/contribsys/faktory/util \
github.com/contribsys/faktory/webui
kill:
@killall -m -9 -e redis || :
# docker buildx create --name cross
# docker buildx use cross
dimg: clean generate ## Make cross-platform Docker images for the current version
GOOS=linux GOARCH=amd64 go build -o tmp/linux/amd64 cmd/faktory/daemon.go
GOOS=linux GOARCH=arm64 go build -o tmp/linux/arm64 cmd/faktory/daemon.go
upx -qq ./tmp/linux/amd64
upx -qq ./tmp/linux/arm64
docker buildx build --tag contribsys/faktory:$(VERSION) --tag contribsys/faktory:latest --load .
dpush: clean generate
GOOS=linux GOARCH=amd64 go build -o tmp/linux/amd64 cmd/faktory/daemon.go
GOOS=linux GOARCH=arm64 go build -o tmp/linux/arm64 cmd/faktory/daemon.go
upx -qq ./tmp/linux/amd64
upx -qq ./tmp/linux/arm64
docker buildx build --platform "linux/arm64,linux/amd64" --tag contribsys/faktory:$(VERSION) --tag contribsys/faktory:latest --push .
drun: ## Run Faktory in a local Docker image, see also "make dimg"
docker run --rm -it -e "FAKTORY_SKIP_PASSWORD=true" \
-v faktory-data:/var/lib/faktory \
-p 127.0.0.1:7419:7419 \
-p 127.0.0.1:7420:7420 \
contribsys/faktory:latest /faktory -e production
dmon: ## Monitor Redis within the running Docker image
docker run --rm -it -t -i \
-v faktory-data:/var/lib/faktory \
contribsys/faktory:latest /usr/bin/redis-cli -s /var/lib/faktory/db/redis.sock monitor
#dinsp:
#docker run --rm -it -e "FAKTORY_PASSWORD=${PASSWORD}" \
#-p 127.0.0.1:7419:7419 \
#-p 127.0.0.1:7420:7420 \
#-v faktory-data:/var/lib/faktory \
#contribsys/faktory:$(VERSION) /bin/bash
generate:
go generate github.com/contribsys/faktory/webui
cover:
go test -coverprofile cover.out \
github.com/contribsys/faktory/cli \
github.com/contribsys/faktory/client \
github.com/contribsys/faktory/manager \
github.com/contribsys/faktory/server \
github.com/contribsys/faktory/storage \
github.com/contribsys/faktory/util \
github.com/contribsys/faktory/webui
go tool cover -html=cover.out -o coverage.html
open coverage.html
xbuild: clean generate
@CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o $(NAME)_amd64 cmd/faktory/daemon.go
# brew install upx
upx -qq ./$(NAME)_amd64
@CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o $(NAME)_arm64 cmd/faktory/daemon.go
# brew install upx
upx -qq ./$(NAME)_arm64
build: clean generate
go build -o $(NAME) cmd/faktory/daemon.go
mon:
redis-cli -s ~/.faktory/db/redis.sock
# this is a separate target because loadtest doesn't need redis or webui
build_load:
go build -o loadtest test/load/main.go
load: # not war
go run test/load/main.go 30000 10
megacheck:
@megacheck $(shell go list -f '{{ .ImportPath }}' ./... | grep -ve vendor | paste -sd " " -) || true
# TODO integrate a few useful Golang linters.
lint:
# brew install golangci/tap/golangci-lint
golangci-lint run
fmt: ## Format the code
go fmt ./...
work: ## Run a simple Ruby worker, see also "make run"
cd test/ruby && bundle exec faktory-worker -v -r ./app.rb -q critical -q default -q bulk
clean: ## Clean the project, set it up for a new build
@rm -rf tmp
@rm -f main $(NAME) $(NAME)_amd64 $(NAME)_arm64 templates.go
@mkdir -p tmp/linux
@go clean -testcache
@rm -rf packaging/output
@mkdir -p packaging/output/upstart
@mkdir -p packaging/output/systemd
run: clean generate ## Run Faktory daemon locally
FAKTORY_PASSWORD=${PASSWORD} go run cmd/faktory/daemon.go -l debug -e development
cssh:
pushd build/centos && vagrant up && vagrant ssh
ussh:
pushd build/ubuntu && vagrant up && vagrant ssh
# gem install fpm
# Packaging uses Go's cross compile + fpm so we can build Linux packages on macOS.
package: clean deb rpm
package_base_name:
@echo $(BASENAME)
version_check:
@grep -q $(VERSION) client/faktory.go || (echo VERSIONS OUT OF SYNC && false)
# these two reload targets are meant to be run within the Vagrant boxes
reload_rpm:
sudo rpm -e $(NAME)
sudo yum install -y packaging/output/systemd/$(NAME)-$(VERSION)-$(ITERATION).x86_64.rpm
reload_deb:
sudo apt-get purge -y $(NAME)
sudo dpkg -i packaging/output/systemd/$(NAME)_$(VERSION)-$(ITERATION)_amd64.deb
rpm: xbuild
@cp $(NAME)_arm64 $(NAME)
fpm -s dir -t rpm -n $(NAME) -v $(VERSION) -p packaging/output/systemd \
--depends redis \
--rpm-compression bzip2 \
--rpm-os linux \
--after-install packaging/scripts/postinst.rpm.systemd \
--before-remove packaging/scripts/prerm.rpm.systemd \
--after-remove packaging/scripts/postrm.rpm.systemd \
--url https://contribsys.com/faktory \
--description "Background job server" \
-m "Contributed Systems LLC <info@contribsys.com>" \
--iteration $(ITERATION) --license "GPL 3.0" \
--vendor "Contributed Systems" -a arm64 \
faktory=/usr/bin/faktory \
packaging/root/=/
@cp -f $(NAME)_amd64 $(NAME)
fpm -s dir -t rpm -n $(NAME) -v $(VERSION) -p packaging/output/systemd \
--depends redis \
--rpm-compression bzip2 \
--rpm-os linux \
--after-install packaging/scripts/postinst.rpm.systemd \
--before-remove packaging/scripts/prerm.rpm.systemd \
--after-remove packaging/scripts/postrm.rpm.systemd \
--url https://contribsys.com/faktory \
--description "Background job server" \
-m "Contributed Systems LLC <info@contribsys.com>" \
--iteration $(ITERATION) --license "GPL 3.0" \
--vendor "Contributed Systems" -a amd64 \
faktory=/usr/bin/faktory \
packaging/root/=/
# @rm $(NAME)
deb: xbuild
@cp $(NAME)_arm64 $(NAME)
fpm -s dir -t deb -n $(NAME) -v $(VERSION) -p packaging/output/systemd \
--depends redis-server \
--deb-priority optional --category admin \
--no-deb-no-default-config-files \
--after-install packaging/scripts/postinst.deb.systemd \
--before-remove packaging/scripts/prerm.deb.systemd \
--after-remove packaging/scripts/postrm.deb.systemd \
--url https://contribsys.com/faktory \
--description "Background job server" \
-m "Contributed Systems LLC <info@contribsys.com>" \
--iteration $(ITERATION) --license "GPL 3.0" \
--vendor "Contributed Systems" -a arm64 \
faktory=/usr/bin/faktory \
packaging/root/=/
@cp -f $(NAME)_amd64 $(NAME)
fpm -s dir -t deb -n $(NAME) -v $(VERSION) -p packaging/output/systemd \
--depends redis-server \
--deb-priority optional --category admin \
--no-deb-no-default-config-files \
--after-install packaging/scripts/postinst.deb.systemd \
--before-remove packaging/scripts/prerm.deb.systemd \
--after-remove packaging/scripts/postrm.deb.systemd \
--url https://contribsys.com/faktory \
--description "Background job server" \
-m "Contributed Systems LLC <info@contribsys.com>" \
--iteration $(ITERATION) --license "GPL 3.0" \
--vendor "Contributed Systems" -a amd64 \
faktory=/usr/bin/faktory \
packaging/root/=/
# @rm $(NAME)
tag:
git tag v$(VERSION) && git push --tags || :
.PHONY: help all clean test build package
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'