Skip to content

Commit

Permalink
Merge pull request #17 from ojagodzinski/master
Browse files Browse the repository at this point in the history
makefile, debian package
  • Loading branch information
zhangjianweibj authored Oct 8, 2019
2 parents 3c28919 + b608230 commit 9863e51
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
build
dist
42 changes: 42 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
APPLICATION_NAME := prometheus-libvirt-exporter
APPLICATION_VERSION := $(shell cat VERSION)

LDFLAGS := -X $(APPLICATION_NAME)/meta.Version=$(APPLICATION_VERSION)

GO_BUILD := go build -v -ldflags "$(LDFLAGS)"

PATH := $(PWD)/build/dependencies:$(PATH)

TEMPDIR := $(shell mktemp -d)

all: build

build_linux:
env GOOS=linux GOARCH=amd64 GO111MODULE=on $(GO_BUILD) -o build/prometheus-libvirt-exporter ./prometheus-libvirt-exporter.go

build:
$(GO_BUILD) -o build/prometheus-libvirt-exporter ./prometheus-libvirt-exporter.go

clean:
go clean -v .
rm -rf build

FPM-exists:
@fpm -v || \
(echo >&2 "FPM must be installed on the system. See https://github.com/jordansissel/fpm"; false)

deb: FPM-exists build_linux
mkdir -p dist/$(APPLICATION_VERSION)/
cd dist/$(APPLICATION_VERSION)/ && \
fpm -s dir \
-t deb \
-n prometheus-libvirt-exporter \
-v $(APPLICATION_VERSION) \
--url="https://github.com/zhangjianweibj/prometheus-libvirt-exporter" \
--description "Prometheus-libvirt-exporter service (host and vm metrics exposed for prometheus, written in Go with pluggable metric collectors)" \
--deb-priority optional \
--workdir $(TEMPDIR) \
--architecture amd64 \
../../build/prometheus-libvirt-exporter=/usr/bin/prometheus-libvirt-exporter \
../../debian/prometheus-libvirt-exporter.service=/etc/systemd/system/prometheus-libvirt-exporter.service \
../../debian/prometheus-libvirt-exporter.upstart=/etc/init/prometheus-libvirt-exporter.conf
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.1
13 changes: 13 additions & 0 deletions debian/prometheus-libvirt-exporter.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[Unit]
Description=Prometheus-libvirt-exporter service (host and vm metrics exposed for prometheus, written in Go with pluggable metric collectors)
Requires=network-online.target
After=network-online.target

[Service]
ExecStart=/usr/bin/prometheus-libvirt-exporter -web.listen-address ":9180"
ExecReload=/bin/kill -HUP $MAINPID
Restart=on-failure
KillSignal=SIGINT

[Install]
WantedBy=multi-user.target
15 changes: 15 additions & 0 deletions debian/prometheus-libvirt-exporter.upstart
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
description "Prometheus-libvirt-exporter service (host and vm metrics exposed for prometheus, written in Go with pluggable metric collectors)"

start on runlevel [2345]
stop on runlevel [!2345]

respawn

script
echo $$ > /var/run/prometheus-libvirt-exporter.pid
exec prometheus-libvirt-exporter -web.listen-address ":9180"
end script

post-stop script
rm -f /var/run/prometheus-libvirt-exporter.pid
end script

0 comments on commit 9863e51

Please sign in to comment.