Use /srv/prometheus instead of /data, because user `prometheus` doens't have permissions to create `/data/` in `/`. Instead this commit puts prometheus data into `/srv/prometheus` by default, which is a cleaner path, and it'll create tsdb path & then assign required permissions on each prometheus service start. This way, also, the cases when users re-configure tsdb to point to external USB - it'll also be created and assigned required permissions for prometheus. Signed-off-by: Alex Simkin <sashasimkin@gmail.com>
33 lines
977 B
Bash
Executable file
33 lines
977 B
Bash
Executable file
#!/bin/sh /etc/rc.common
|
|
|
|
START=70
|
|
|
|
USE_PROCD=1
|
|
PROG=/usr/bin/prometheus
|
|
CONFFILE=/etc/prometheus.yml
|
|
|
|
start_service() {
|
|
local config_file
|
|
local storage_tsdb_path
|
|
local web_listen_address
|
|
config_load "prometheus"
|
|
config_get config_file prometheus config_file "$CONFFILE"
|
|
config_get storage_tsdb_path prometheus storage_tsdb_path "/srv/prometheus"
|
|
config_get web_listen_address prometheus web_listen_address "127.0.0.1:9090"
|
|
|
|
# Create tsdb dir & permissions if needed
|
|
if [ ! -d "$storage_tsdb_path" ]; then
|
|
mkdir "$storage_tsdb_path"
|
|
chown prometheus:prometheus "$storage_tsdb_path"
|
|
fi;
|
|
|
|
procd_open_instance
|
|
procd_set_param command "$PROG"
|
|
procd_append_param command --config.file="$config_file"
|
|
procd_append_param command --storage.tsdb.path="$storage_tsdb_path"
|
|
procd_append_param command --web.listen-address="$web_listen_address"
|
|
procd_append_param user "prometheus"
|
|
procd_set_param file "$config_file"
|
|
procd_set_param respawn
|
|
procd_close_instance
|
|
}
|