#!/sbin/openrc-run
name="prometheus"
description="prometheus monitoring system & time series database"
supervisor=supervise-daemon
command=/usr/bin/prometheus
command_args="--config.file=$prometheus_config_file \
	--storage.tsdb.path=$prometheus_storage_path \
	--storage.tsdb.retention.time=$prometheus_retention_time
	$prometheus_args"
command_user="prometheus:prometheus"
extra_started_commands="reload"

# prometheus need to open a lot chunks
rc_ulimit="${prometheus_ulimit:--n 65536}"

start_pre() {
	[ -n "$output_log" ] && checkpath -f "$output_log" \
		-m 644 -o prometheus:prometheus
	[ -n "$error_log" ] && checkpath -f "$error_log" \
		-m 644 -o prometheus:prometheus
	checkpath -d "$prometheus_storage_path" -m 755 -o prometheus:prometheus
}

reload() {
	ebegin "Reloading $RC_SVCNAME"
	supervise-daemon $RC_SVCNAME --signal HUP
	eend $?
}
