forked from contribsys/faktory
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
212 lines (175 loc) · 7.34 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
NAME=faktory
VERSION=0.5.0
# 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
# contains various secret or machine-specific variables.
# DEB_PRODUCTION: hostname of a debian-based upstart machine (e.g. Ubuntu {12,14}.04 LTS)
# RPM_PRODUCTION: hostname of a redhat-based systemd machine (e.g. CentOS 7)
#include $(HOME)/.local.sh
# TODO I'd love some help making this a proper Makefile
# with real file dependencies.
all: test
# install dependencies and cli tools
prepare:
@go get github.com/golang/dep/cmd/dep
@dep ensure
@go get github.com/benbjohnson/ego/cmd/ego
@go get github.com/jteeuwen/go-bindata/go-bindata
@echo Now you should be ready to run "make"
test: clean generate
go test $(TEST_FLAGS) \
github.com/contribsys/faktory \
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
d:
#eval $(shell docker-machine env default)
GOLANG_VERSION=1.9.1 ROCKSDB_VERSION=5.7.3 TAG=$(VERSION) docker-compose build
drun:
docker run --rm -it -p 7419:7419 -p 7420:7420 contribsys/faktory:$(VERSION) -b :7419 -no-tls
generate:
go generate github.com/contribsys/faktory/webui
cover:
go test -cover -coverprofile cover.out github.com/contribsys/faktory/server
go tool cover -html=cover.out -o coverage.html
/Applications/Firefox.app/Contents/MacOS/firefox coverage.html
# we can't cross-compile when using cgo <cry>
# @GOOS=linux GOARCH=amd64
build: clean generate
go build -o faktory-cli cmd/repl.go
go build -o faktory cmd/daemon.go
# TODO integrate a few useful Golang linters.
fmt:
go fmt ./...
# trigger TLS for testing
swork:
cd test/ruby && FAKTORY_PROVIDER=FURL \
FURL=tcp://:password123@localhost.contribsys.com:7419 \
bundle exec faktory-worker -v -r ./app.rb -q critical -q default -q bulk
# no TLS, just plain text against localhost
work:
cd test/ruby && bundle exec faktory-worker -v -r ./app.rb -q critical -q default -q bulk
clean:
@rm -f webui/*.ego.go
@rm -rf tmp
@rm -f main faktory templates.go faktory-cli
@rm -rf packaging/output
@mkdir -p packaging/output/upstart
@mkdir -p packaging/output/systemd
repl: clean generate
go run cmd/repl.go -l debug -e development
run: clean generate
go run cmd/daemon.go -l debug -e development
srun: clean generate
FAKTORY_PASSWORD=password123 go run cmd/daemon.go -b 127.0.0.1:7419 -l debug -e development
cssh:
pushd build/centos && vagrant up && vagrant ssh
ussh:
pushd build/ubuntu && vagrant up && vagrant ssh
# gem install fpm
# https://github.com/jordansissel/fpm/issues/576
# brew install gnu-tar
# ln -s /usr/local/bin/gtar /usr/local/bin/gnutar
package: version_check clean build build_deb_systemd build_rpm_systemd
version_check:
@grep -q $(VERSION) faktory.go || (echo VERSIONS OUT OF SYNC && false)
purge_deb:
ssh -t $(DEB_PRODUCTION) 'sudo apt-get purge -y $(NAME) && sudo rm -f /etc/faktory' || true
purge_rpm:
ssh -t $(RPM_PRODUCTION) 'sudo rpm -e $(NAME) && sudo rm -f /etc/faktory' || true
deploy_deb: clean build_deb purge_deb
scp packaging/output/upstart/*.deb $(DEB_PRODUCTION):~
ssh $(DEB_PRODUCTION) 'sudo rm -f /etc/faktory && sudo dpkg -i $(NAME)_$(VERSION)-$(ITERATION)_amd64.deb && sudo ./fix && sudo restart faktory || true'
deploy_rpm: clean build_rpm purge_rpm
scp packaging/output/systemd/*.rpm $(RPM_PRODUCTION):~
ssh -t $(RPM_PRODUCTION) 'sudo rm -f /etc/faktory && sudo yum install -q -y $(NAME)-$(VERSION)-$(ITERATION).x86_64.rpm && sudo ./fix && sudo systemctl restart faktory'
update_deb: clean build_deb
scp packaging/output/upstart/*.deb $(DEB_PRODUCTION):~
ssh $(DEB_PRODUCTION) 'sudo dpkg -i $(NAME)_$(VERSION)-$(ITERATION)_amd64.deb'
update_rpm: clean build_rpm
scp packaging/output/systemd/*.rpm $(RPM_PRODUCTION):~
ssh -t $(RPM_PRODUCTION) 'sudo yum install -q -y $(NAME)-$(VERSION)-$(ITERATION).x86_64.rpm'
deploy: deploy_deb deploy_rpm
purge: purge_deb purge_rpm
build_rpm_upstart:
# gem install fpm
# brew install rpm
fpm -s dir -t rpm -n $(NAME) -v $(VERSION) -p packaging/output/upstart \
--rpm-compression bzip2 --rpm-os linux \
--after-install packaging/scripts/postinst.rpm.upstart \
--before-remove packaging/scripts/prerm.rpm.upstart \
--after-remove packaging/scripts/postrm.rpm.upstart \
--url http://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 \
faktory-cli=/usr/bin/faktory-cli \
packaging/root/=/
build_rpm_systemd:
# gem install fpm
# brew install rpm
fpm -s dir -t rpm -n $(NAME) -v $(VERSION) -p packaging/output/systemd \
--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 http://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 \
faktory-cli=/usr/bin/faktory-cli \
packaging/root/=/
build_deb_upstart:
# gem install fpm
fpm -s dir -t deb -n $(NAME) -v $(VERSION) -p packaging/output/upstart \
--deb-priority optional --category admin \
--deb-compression bzip2 \
--no-deb-no-default-config-files \
--after-install packaging/scripts/postinst.deb.upstart \
--before-remove packaging/scripts/prerm.deb.upstart \
--after-remove packaging/scripts/postrm.deb.upstart \
--url http://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 \
faktory-cli=/usr/bin/faktory-cli \
packaging/root/=/
build_deb_systemd:
# gem install fpm
fpm -s dir -t deb -n $(NAME) -v $(VERSION) -p packaging/output/systemd \
--deb-priority optional --category admin \
--deb-compression bzip2 \
--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 http://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 \
faktory-cli=/usr/bin/faktory-cli \
packaging/root/=/
tag:
git tag v$(VERSION)-$(ITERATION) && git push --tags || :
upload: package tag
# gem install -N package_cloud
package_cloud push contribsys/faktory/ubuntu/xenial packaging/output/systemd/$(NAME)_$(VERSION)-$(ITERATION)_amd64.deb
#package_cloud push contribsys/faktory/ubuntu/trusty packaging/output/upstart/$(NAME)_$(VERSION)-$(ITERATION)_amd64.deb
package_cloud push contribsys/faktory/el/7 packaging/output/systemd/$(NAME)-$(VERSION)-$(ITERATION).x86_64.rpm
#package_cloud push contribsys/faktory/el/6 packaging/output/upstart/$(NAME)-$(VERSION)-$(ITERATION).x86_64.rpm
.PHONY: all clean test build package upload