@@ -43,9 +43,7 @@ const (
4343
4444// postgres_exporter command flags
4545var (
46- ExporterExtendQueryPathFlag = "--extend.query-path=/tmp/queries.yml"
47- ExporterWebListenAddressFlag = fmt .Sprintf ("--web.listen-address=:%d" , ExporterPort )
48- ExporterWebConfigFileFlag = "--web.config.file=/web-config/web-config.yml"
46+ ExporterWebConfigFileFlag = "--web.config.file=/web-config/web-config.yml"
4947)
5048
5149// Defaults for certain values used in queries.yml
@@ -120,26 +118,31 @@ func GenerateDefaultExporterQueries(ctx context.Context, cluster *v1beta1.Postgr
120118// ExporterStartCommand generates an entrypoint that will create a master queries file and
121119// start the postgres_exporter. It will repeat those steps if it notices a change in
122120// the source queries files.
123- func ExporterStartCommand (commandFlags [] string ) []string {
121+ func ExporterStartCommand (commandFlags ... string ) []string {
124122script := strings .Join ([]string {
125123// Older images do not have the command on the PATH.
126124`PATH="$PATH:$(echo /opt/cpm/bin/postgres_exporter-*)"` ,
127125
128126// Set up temporary file to hold postgres_exporter process id
129127`POSTGRES_EXPORTER_PIDFILE=/tmp/postgres_exporter.pid` ,
130128
129+ `postgres_exporter_flags=(` ,
130+ `'--extend.query-path=/tmp/queries.yml'` ,
131+ fmt .Sprintf (`'--web.listen-address=:%d'` , ExporterPort ),
132+ `"$@")` ,
133+
131134// declare function that will combine custom queries file and default
132135// queries and start the postgres_exporter
133136`start_postgres_exporter() {` ,
134- ` cat /conf/* > /tmp/queries.yml` ,
135- ` echo "Starting postgres_exporter with the following flags..."` ,
136- ` echo "$@ "` ,
137- ` postgres_exporter "$@ " &` ,
138- ` echo $! > $POSTGRES_EXPORTER_PIDFILE` ,
137+ ` cat /conf/* > /tmp/queries.yml` ,
138+ ` echo "Starting postgres_exporter with the following flags..."` ,
139+ ` echo "${postgres_exporter_flags[@]} "` ,
140+ ` postgres_exporter "${postgres_exporter_flags[@]} " &` ,
141+ ` echo $! > $POSTGRES_EXPORTER_PIDFILE` ,
139142`}` ,
140143
141144// run function to combine queries files and start postgres_exporter
142- `start_postgres_exporter "$@" ` ,
145+ `start_postgres_exporter` ,
143146
144147// Create a file descriptor with a no-op process that will not get
145148// cleaned up
@@ -153,7 +156,7 @@ func ExporterStartCommand(commandFlags []string) []string {
153156// something must have changed, so kill the postgres_exporter and rerun
154157// the function to combine queries files and start postgres_exporter
155158` if ([ "/conf" -nt "/proc/self/fd/${fd}" ] || [ "/opt/crunchy/password" -nt "/proc/self/fd/${fd}" ]) \` ,
156- ` && kill $(head -1 ${POSTGRES_EXPORTER_PIDFILE?}) && start_postgres_exporter "$@" ;` ,
159+ ` && kill $(head -1 ${POSTGRES_EXPORTER_PIDFILE?}) && start_postgres_exporter;` ,
157160` then` ,
158161
159162// When something changes we want to get rid of the old file descriptor, get a fresh one
0 commit comments