change database configuration to env vars

This commit is contained in:
2023-09-27 11:36:54 +02:00
parent f24cdbac1c
commit 73567d3230
2 changed files with 7 additions and 9 deletions

View File

@ -2,6 +2,12 @@ FROM alpine:3.18.3 AS builder
ARG VERSION="dockerized"
ENV PGHOST ""
ENV PGDATABASE "mainscnt"
ENV PGUSER "sink"
ENV PGPASSWORD ""
ENV PGSSLMODE "require"
COPY sink/ /tmp/sink
RUN \

View File

@ -47,7 +47,6 @@ typedef struct {
int receiveSockFd;
int32_t lowerBound;
int32_t upperBound;
const char *postgresqlConnInfo;
PGconn *conn;
t_device foundDevice;
} t_commonHandle;
@ -61,7 +60,7 @@ int openDatabaseConnection(t_commonHandle *handle) {
if (! handle->conn) {
logmsg(LOG_DEBUG, "Opening connection to database");
handle->conn = PQconnectdb(handle->postgresqlConnInfo);
handle->conn = PQconnectdb();
} else if (PQstatus(handle->conn) != CONNECTION_OK) {
logmsg(LOG_DEBUG, "Resetting connection to database");
PQreset(handle->conn);
@ -234,13 +233,6 @@ int receiveAndVerifyMinuteBuffer(t_commonHandle *handle, t_minuteBuffer *buf) {
int initForwarder(t_configHandle *configHandle, t_commonHandle *handle) {
handle->configHandle = configHandle;
handle->postgresqlConnInfo = NULL;
config_lookup_string(&(configHandle->cfg), "postgresqlConnInfo", &(handle->postgresqlConnInfo));
if (! handle->postgresqlConnInfo) {
logmsg(LOG_ERR, "no postgresql connInfo configured");
return -1;
}
handle->conn = NULL;
handle->lowerBound = 45000;