diff --git a/app-metrics/sql_exporter/files/sql_exporter.init.d b/app-metrics/sql_exporter/files/sql_exporter.init.d index 88ebac4e..fca12936 100644 --- a/app-metrics/sql_exporter/files/sql_exporter.init.d +++ b/app-metrics/sql_exporter/files/sql_exporter.init.d @@ -6,9 +6,11 @@ name="sql_exporter daemon" description="SQL Exporter allows to run custom queries against a database" command="/usr/bin/sql_exporter" command_args="-config.file /etc/sql_exporter/sql_exporter.yml" -start_stop_daemon_args="--user sql_exporter" -output_log="/var/log/sql_exporter/sql_exporter.log" -error_log="/var/log/sql_exporter/sql_exporter.log" +stdout_log="/var/log/sql_exporter/sql_exporter.log" +stderr_log="/var/log/sql_exporter/sql_exporter.log" +start_stop_daemon_args="--background --user sql_exporter \ + --stdout $stdout_log \ + --stderr $stderr_log" depend() { need net diff --git a/app-metrics/sql_exporter/files/sql_exporter.yml b/app-metrics/sql_exporter/files/sql_exporter.yml index da288640..f07ddce9 100644 --- a/app-metrics/sql_exporter/files/sql_exporter.yml +++ b/app-metrics/sql_exporter/files/sql_exporter.yml @@ -2,16 +2,16 @@ # jobs is a map of jobs, define any number but please keep the connection usage on the DBs in mind jobs: # each job needs a unique name, it's used for logging and as an default label -- name: "example" +- name: "postgres" # interval defined the pause between the runs of this job - interval: '5m' + interval: '1m' # cron_schedule when to execute the job in the standard CRON syntax # if specified, the interval is ignored - cron_schedule: "0 0 * * *" + #cron_schedule: "0 0 * * *" # connections is an array of connection URLs # each query will be executed on each connection connections: - - 'postgres://postgres@localhost/postgres?sslmode=disable' + - 'postgres://sql_exporter@/?host=/run/postgresql&dbname=postgres&sslmode=disable' # startup_sql is an array of SQL statements # each statements is executed once after connecting startup_sql: diff --git a/app-metrics/sql_exporter/sql_exporter-0.5.3.ebuild b/app-metrics/sql_exporter/sql_exporter-0.5.3.ebuild index 8a3cf388..f1bba514 100644 --- a/app-metrics/sql_exporter/sql_exporter-0.5.3.ebuild +++ b/app-metrics/sql_exporter/sql_exporter-0.5.3.ebuild @@ -26,31 +26,34 @@ EGO_PN="github.com/justwatchcom/sql_exporter" src_prepare() { default - cd "${S}" || die + cd "${S}" export GO111MODULE=auto } src_compile() { export GOPATH="${S}" - cd "${S}/src/${EGO_PN}" || die - echo "compiling from $(pwd)" || die - go build -o "${S}/bin/sql_exporter" || die "Failed to build sql_exporter" + cd "${S}/src/${EGO_PN}" + echo "compiling from $(pwd)" + go build -o "${S}/bin/sql_exporter" } src_test() { - cd "${S}/src/${EGO_PN}" || die - go test -v ./... || die "Tests failed" + cd "${S}/src/${EGO_PN}" + go test -v ./... } src_install() { - dobin "${S}/bin/sql_exporter" - newinitd "${FILESDIR}/sql_exporter.init.d" sql_exporter - dosym /etc/init.d/sql_exporter /etc/runlevels/default/sql_exporter || die + dobin "${S}/bin/sql_exporter" + newinitd "${FILESDIR}/sql_exporter.init.d" sql_exporter + dosym /etc/init.d/sql_exporter /etc/runlevels/default/sql_exporter - insinto /etc/sql_exporter - doins "${FILESDIR}/sql_exporter.yml" + insinto /etc/sql_exporter + doins "${FILESDIR}/sql_exporter.yml" - # Create log directory and file - dodir /var/log/sql_exporter - touch "${ED}"/var/log/sql_exporter/sql_exporter.log || die "failed to create log file" + # Create log directory and file + dodir /var/log/sql_exporter + touch "${ED}"/var/log/sql_exporter/sql_exporter.log + + # Change ownership of the log file to sql_exporter + chown sql_exporter:sql_exporter "${ED}"/var/log/sql_exporter/sql_exporter.log }