-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge in Concourse changes + Centos 7 (#143)
* Add systemd and centos7 support. * Make the shipper happy for now. * Add a version to the binary.
- Loading branch information
Showing
9 changed files
with
200 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
DEFAULT: build | ||
|
||
GOPATH := ${CURDIR} | ||
GOFMT ?= gofmt | ||
APP := caduceus | ||
FIRST_GOPATH := $(firstword $(subst :, ,$(shell go env GOPATH))) | ||
BINARY := $(FIRST_GOPATH)/bin/$(APP) | ||
|
||
PROGVER = $(shell grep 'applicationVersion.*= ' src/$(APP)/$(APP).go | awk '{print $$3}' | sed -e 's/\"//g') | ||
RELEASE = 1 | ||
|
||
.PHONY: glide-install | ||
glide-install: | ||
export GOPATH=$(GOPATH) && cd src && glide install --strip-vendor | ||
|
||
.PHONY: build | ||
build: glide-install | ||
export GOPATH=$(GOPATH) && cd src/$(APP) && go build | ||
|
||
rpm: | ||
mkdir -p ./.ignore/SOURCES | ||
tar -czf ./.ignore/SOURCES/$(APP)-$(PROGVER).tar.gz --transform 's/^\./$(APP)-$(PROGVER)/' --exclude ./keys --exclude ./.git --exclude ./.ignore --exclude ./conf --exclude ./deploy --exclude ./vendor --exclude ./src/vendor . | ||
cp etc/systemd/$(APP).service ./.ignore/SOURCES/ | ||
cp etc/$(APP)/$(APP).yaml ./.ignore/SOURCES/ | ||
rpmbuild --define "_topdir $(CURDIR)/.ignore" \ | ||
--define "_ver $(PROGVER)" \ | ||
--define "_releaseno $(RELEASE)" \ | ||
-ba etc/systemd/$(APP).spec | ||
|
||
.PHONY: version | ||
version: | ||
@echo $(PROGVER) | ||
|
||
|
||
# If the first argument is "update-version"... | ||
ifeq (update-version,$(firstword $(MAKECMDGOALS))) | ||
# use the rest as arguments for "update-version" | ||
RUN_ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS)) | ||
# ...and turn them into do-nothing targets | ||
$(eval $(RUN_ARGS):;@:) | ||
endif | ||
|
||
.PHONY: update-version | ||
update-version: | ||
@echo "Update Version $(PROGVER) to $(RUN_ARGS)" | ||
sed -i "s/$(PROGVER)/$(RUN_ARGS)/g" src/$(APP)/$(APP).go | ||
|
||
|
||
.PHONY: install | ||
install: | ||
echo go build -o $(BINARY) $(PROGVER) | ||
|
||
.PHONY: release-artifacts | ||
release-artifacts: glide-install | ||
mkdir -p ./.ignore | ||
export GOPATH=$(GOPATH) && cd src/$(APP) && GOOS=darwin GOARCH=amd64 go build -o ../../.ignore/$(APP)-$(PROGVER).darwin-amd64 | ||
export GOPATH=$(GOPATH) && cd src/$(APP) && GOOS=linux GOARCH=amd64 go build -o ../../.ignore/$(APP)-$(PROGVER).linux-amd64 | ||
|
||
.PHONY: docker | ||
docker: | ||
docker build -f ./deploy/Dockerfile -t $(APP):$(PROGVER) . | ||
|
||
# build docker without running modules | ||
.PHONY: local-docker | ||
local-docker: | ||
GOOS=linux GOARCH=amd64 go build -o $(APP)_linux_amd64 | ||
docker build -f ./deploy/Dockerfile.local -t $(APP):local . | ||
|
||
.PHONY: style | ||
style: | ||
! gofmt -d $$(find . -path ./vendor -prune -o -name '*.go' -print) | grep '^' | ||
|
||
.PHONY: test | ||
test: | ||
go test -o $(BINARY) -v -race -coverprofile=cover.out $(go list ./... | grep -v "/vendor/") | ||
|
||
.PHONY: test-cover | ||
test-cover: test | ||
go tool cover -html=cover.out | ||
|
||
.PHONY: codecov | ||
codecov: test | ||
curl -s https://codecov.io/bash | bash | ||
|
||
.PHONEY: it | ||
it: | ||
./it.sh | ||
|
||
.PHONY: clean | ||
clean: | ||
rm -rf ./$(APP) ./.ignore ./coverage.txt ./vendor ./src/vendor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,17 @@ | ||
[Unit] | ||
Description=The Xmidt server for delivering events. | ||
After=network.target | ||
After=network.target remote-fs.target nss-lookup.target | ||
|
||
[Service] | ||
Type=simple | ||
User=caduceus | ||
PIDFile=/run/caduceus.pid | ||
ExecStartPre=/usr/bin/rm -f /run/caduceus.pid | ||
ExecStart=/usr/bin/caduceus | ||
Restart=on-failure | ||
ExecReload=/bin/kill -s HUP $MAINPID | ||
TimeoutStopSec=10 | ||
KillMode=process | ||
PrivateTmp=true | ||
Restart=always | ||
|
||
[Install] | ||
WantedBy=multi-user.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
%define debug_package %{nil} | ||
|
||
Name: caduceus | ||
Version: %{_ver} | ||
Release: %{_releaseno}%{?dist} | ||
Summary: The Xmidt API interface server. | ||
|
||
Group: System Environment/Daemons | ||
License: ASL 2.0 | ||
URL: https://github.com/Comcast/%{name} | ||
Source0: %{name}-%{version}.tar.gz | ||
|
||
BuildRequires: golang >= 1.11 | ||
|
||
Provides: %{name} | ||
|
||
%description | ||
The Xmidt API interface server. | ||
|
||
%prep | ||
%setup -q | ||
|
||
%build | ||
export GOPATH=$(pwd) | ||
pushd src | ||
glide i --strip-vendor | ||
cd %{name} | ||
go build %{name} | ||
popd | ||
|
||
%install | ||
|
||
# Install Binary | ||
%{__install} -D -p -m 755 src/%{name}/%{name} %{buildroot}%{_bindir}/%{name} | ||
|
||
# Install Service | ||
%{__install} -D -p -m 644 etc/systemd/%{name}.service %{buildroot}%{_unitdir}/%{name}.service | ||
|
||
# Install Configuration | ||
%{__install} -D -p -m 644 etc/%{name}/%{name}.yaml %{buildroot}%{_sysconfdir}/%{name}/%{name}.yaml | ||
|
||
|
||
# Create Logging Location | ||
%{__install} -d %{buildroot}%{_localstatedir}/log/%{name} | ||
|
||
# Create Runtime Details Location | ||
%{__install} -d %{buildroot}%{_localstatedir}/run/%{name} | ||
|
||
%files | ||
%defattr(-, %{name}, %{name}, -) | ||
|
||
# Binary | ||
%attr(755, %{name}, %{name}) %{_bindir}/%{name} | ||
|
||
# Configuration | ||
%dir %{_sysconfdir}/%{name} | ||
%config(noreplace) %{_sysconfdir}/%{name}/%{name}.yaml | ||
|
||
# Service Files | ||
%{_unitdir}/%{name}.service | ||
|
||
# Logging Location | ||
%dir %{_localstatedir}/log/%{name} | ||
|
||
# Runtime Details Location | ||
%dir %{_localstatedir}/run/%{name} | ||
|
||
%pre | ||
# If app user does not exist, create | ||
id %{name} >/dev/null 2>&1 | ||
if [ $? != 0 ]; then | ||
/usr/sbin/groupadd -r %{name} >/dev/null 2>&1 | ||
/usr/sbin/useradd -d /var/run/%{name} -r -g %{name} %{name} >/dev/null 2>&1 | ||
fi | ||
|
||
|
||
%post | ||
%systemd_post %{name}.service | ||
|
||
%preun | ||
%systemd_preun %{name}.service | ||
|
||
%postun | ||
%systemd_postun %{name}.service | ||
|
||
# Do not remove anything if this is not an uninstall | ||
if [ $1 = 0 ]; then | ||
/usr/sbin/userdel -r %{name} >/dev/null 2>&1 | ||
/usr/sbin/groupdel %{name} >/dev/null 2>&1 | ||
# Ignore errors from above | ||
true | ||
fi | ||
|
||
%changelog |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters