Skip to content

Commit

Permalink
sql_exporter: adding package plus config, user and group
Browse files Browse the repository at this point in the history
  • Loading branch information
leomuso committed Apr 15, 2024
1 parent b5857ab commit 38d8290
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
8 changes: 5 additions & 3 deletions app-metrics/sql_exporter/files/sql_exporter.init.d
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app-metrics/sql_exporter/files/sql_exporter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
# connections is an array of connection URLs
# each query will be executed on each connection
connections:
- 'postgres://postgres@localhost/postgres?sslmode=disable'
- 'postgres://postgres@/run/postgresql/postgres?sslmode=disable'
# startup_sql is an array of SQL statements
# each statements is executed once after connecting
startup_sql:
Expand Down
16 changes: 8 additions & 8 deletions app-metrics/sql_exporter/sql_exporter-0.5.3.ebuild
Original file line number Diff line number Diff line change
Expand Up @@ -26,31 +26,31 @@ 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
dosym /etc/init.d/sql_exporter /etc/runlevels/default/sql_exporter

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"
touch "${ED}"/var/log/sql_exporter/sql_exporter.log
}

0 comments on commit 38d8290

Please sign in to comment.