Sidekiq无法连接到postgresql数据库

zrfyljdw  于 2022-12-12  发布在  PostgreSQL
关注(0)|答案(1)|浏览(769)

I am attempting to deploy sidekiq as a sidecar container alongside Discourse and I am receiving the following error
2022-05-31T02:57:01.242Z pid=1 tid=cd1 WARN: ActiveRecord::ConnectionNotEstablished: could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
Both Sidekiq and Discourse uses the same bitnami docker image with the only difference is the Sidekiq container has a run file thats ran to start sidekiq. The postgreql server I am connecting to is an existing server and Discourse itself doesn't seem to have any issues connecting to it. I have looked at the run file for sidekiq and I don't think it's pulling the env variables properly. I have tried various different variable notations thinking it was a syntax issue. Below is the deployment I am using, Any insight would be greatly appreciated

containers:
      - name:  discourse
        image: bitnami/discourse
        livenessProbe:
          tcpSocket:
            port: 3000
          initialDelaySeconds: 90
          periodSeconds: 90          
        env:
          - name: DISCOURSE_HOST
            value: "xxx"
          - name: DISCOURSE_DATABASE_HOST
            value: "my-release-postgresql.default"
          - name: DISCOURSE_DATABASE_PORT_NUMBER
            value: "5432"
          - name: DISCOURSE_DATABASE_USER
            value: "postgres"
          - name: DISCOURSE_DATABASE_PASSWORD
            value: "xxx"
          - name: DISCOURSE_DATABASE_NAME
            value: "bitnami_discourse"
          - name: DISCOURSE_REDIS_HOST
            value: "redis.redis"
          - name: DISCOURSE_REDIS_PORT_NUMER
            value: "6379"
          - name: POSTGRESQL_CLIENT_DATABASE_HOST
            value: "my-release-postgresql.default"
          - name: POSTGRESQL_CLIENT_DATABASE_PORT_NUMBER
            value: "5432"
          - name: POSTGRESQL_CLIENT_POSTGRES_USER
            value: "postgres"
          - name: POSTGRESQL_CLIENT_POSTGRES_PASSWORD
            value: "xxx"
          - name: POSTGRESQL_CLIENT_CREATE_DATABASE_NAME
            value: "bitnami_discourse"
          - name: POSTGRESQL_HOST
            value: "my-release-postgresql.default"
          - name: POSTGRESQL_PORT_NUMBER
            value: "5432"
          - name: DISCOURSE_POSTGRESQL_USERNAME
            value: "postgres"
          - name: DISCOURSE_POSTGRESQL_PASSWORD
            value: "xxx"
          - name: DISCOURSE_POSTGRESQL_NAME
            value: "bitnami_discourse"
          - name: DISCOURSE_SMTP_HOST
            value: "smtp.mailgun.com"
          - name: DISCOURSE_SMTP_PORT
            value: "587"
          - name: DISCOURSE_SMTP_USER
            value: "xxx"
          - name: DISCOURSE_SMTP_PASSWORD
            value: "xxx"
          - name: DISCOURSE_SMTP_PROTOCOL
            value: "tls"                       
        ports:
        - name: portone
          containerPort: 3000
        - name: porttwo
          containerPort: 5432
        - name: portthree
          containerPort: 6379                    
        volumeMounts:
        - mountPath: "/bitnami/discourse"
          name: discourse 
      - name: sidekiq
        image: docker.io/bitnami/discourse
        command: ["/opt/bitnami/scripts/discourse-sidekiq/run.sh"]
        env:
          - name: DISCOURSE_HOST
            value: "xxx"
          - name: DISCOURSE_DATABASE_HOST
            value: "my-release-postgresql.default"
          - name: DISCOURSE_DATABASE_PORT_NUMBER
            value: "5432"
          - name: DISCOURSE_DATABASE_USER
            value: "postgres"
          - name: DISCOURSE_DATABASE_PASSWORD
            value: "xxx"
          - name: DISCOURSE_DATABASE_NAME
            value: "bitnami_discourse"
          - name: DISCOURSE_REDIS_HOST
            value: "redis.redis"
          - name: DISCOURSE_REDIS_PORT_NUMER
            value: "6379"           
          - name: DISCOURSE_SMTP_HOST
            value: "smtp.mailgun.com"
          - name: DISCOURSE_SMTP_PORT
            value: "587"
          - name: DISCOURSE_SMTP_USER
            value: "xxx"
          - name: DISCOURSE_SMTP_PASSWORD
            value: "xxx"
          - name: DISCOURSE_SMTP_PROTOCOL
            value: "tls"
          - name: POSTGRESQL_HOST
            value: "my-release-postgresql.default"
          - name: POSTGRESQL_PORT_NUMBER
            value: "5432"
          - name: DISCOURSE_POSTGRESQL_USERNAME
            value: "postgres"
          - name: DISCOURSE_POSTGRESQL_PASSWORD
            value: "xxx"
          - name: DISCOURSE_POSTGRESQL_NAME
            value: "bitnami_discourse"
          - name: POSTGRESQL_CLIENT_DATABASE_HOST
            value: "my-release-postgresql.default"
          - name: POSTGRESQL_CLIENT_DATABASE_PORT_NUMBER
            value: "5432"
          - name: POSTGRESQL_CLIENT_POSTGRES_USER
            value: "postgres"
          - name: POSTGRESQL_CLIENT_POSTGRES_PASSWORD
            value: "xxx"
roejwanj

roejwanj1#

Hello you need to add one more command ./opt/bitnami/scripts/discourse-sidekiq/setup.sh in sidekiq container command.
e.g

containers:
      - name:  discourse
        image: bitnami/discourse
        livenessProbe:
          tcpSocket:
            port: 3000
          initialDelaySeconds: 90
          periodSeconds: 90          
        env:
          - name: DISCOURSE_HOST
            value: "xxx"
          - name: DISCOURSE_DATABASE_HOST
            value: "my-release-postgresql.default"
          - name: DISCOURSE_DATABASE_PORT_NUMBER
            value: "5432"
          - name: DISCOURSE_DATABASE_USER
            value: "postgres"
          - name: DISCOURSE_DATABASE_PASSWORD
            value: "xxx"
          - name: DISCOURSE_DATABASE_NAME
            value: "bitnami_discourse"
          - name: DISCOURSE_REDIS_HOST
            value: "redis.redis"
          - name: DISCOURSE_REDIS_PORT_NUMER
            value: "6379"
          - name: POSTGRESQL_CLIENT_DATABASE_HOST
            value: "my-release-postgresql.default"
          - name: POSTGRESQL_CLIENT_DATABASE_PORT_NUMBER
            value: "5432"
          - name: POSTGRESQL_CLIENT_POSTGRES_USER
            value: "postgres"
          - name: POSTGRESQL_CLIENT_POSTGRES_PASSWORD
            value: "xxx"
          - name: POSTGRESQL_CLIENT_CREATE_DATABASE_NAME
            value: "bitnami_discourse"
          - name: POSTGRESQL_HOST
            value: "my-release-postgresql.default"
          - name: POSTGRESQL_PORT_NUMBER
            value: "5432"
          - name: DISCOURSE_POSTGRESQL_USERNAME
            value: "postgres"
          - name: DISCOURSE_POSTGRESQL_PASSWORD
            value: "xxx"
          - name: DISCOURSE_POSTGRESQL_NAME
            value: "bitnami_discourse"
          - name: DISCOURSE_SMTP_HOST
            value: "smtp.mailgun.com"
          - name: DISCOURSE_SMTP_PORT
            value: "587"
          - name: DISCOURSE_SMTP_USER
            value: "xxx"
          - name: DISCOURSE_SMTP_PASSWORD
            value: "xxx"
          - name: DISCOURSE_SMTP_PROTOCOL
            value: "tls"                       
        ports:
        - name: portone
          containerPort: 3000
        - name: porttwo
          containerPort: 5432
        - name: portthree
          containerPort: 6379                    
        volumeMounts:
        - mountPath: "/bitnami/discourse"
          name: discourse 
      - name: sidekiq
        image: docker.io/bitnami/discourse
        command:
        - bash
        - -c
        - |
          ./opt/bitnami/scripts/discourse-sidekiq/setup.sh
          ./opt/bitnami/scripts/discourse-sidekiq/run.sh
        env:
          - name: DISCOURSE_HOST
            value: "xxx"
          - name: DISCOURSE_DATABASE_HOST
            value: "my-release-postgresql.default"
          - name: DISCOURSE_DATABASE_PORT_NUMBER
            value: "5432"
          - name: DISCOURSE_DATABASE_USER
            value: "postgres"
          - name: DISCOURSE_DATABASE_PASSWORD
            value: "xxx"
          - name: DISCOURSE_DATABASE_NAME
            value: "bitnami_discourse"
          - name: DISCOURSE_REDIS_HOST
            value: "redis.redis"
          - name: DISCOURSE_REDIS_PORT_NUMER
            value: "6379"           
          - name: DISCOURSE_SMTP_HOST
            value: "smtp.mailgun.com"
          - name: DISCOURSE_SMTP_PORT
            value: "587"
          - name: DISCOURSE_SMTP_USER
            value: "xxx"
          - name: DISCOURSE_SMTP_PASSWORD
            value: "xxx"
          - name: DISCOURSE_SMTP_PROTOCOL
            value: "tls"
          - name: POSTGRESQL_HOST
            value: "my-release-postgresql.default"
          - name: POSTGRESQL_PORT_NUMBER
            value: "5432"
          - name: DISCOURSE_POSTGRESQL_USERNAME
            value: "postgres"
          - name: DISCOURSE_POSTGRESQL_PASSWORD
            value: "xxx"
          - name: DISCOURSE_POSTGRESQL_NAME
            value: "bitnami_discourse"
          - name: POSTGRESQL_CLIENT_DATABASE_HOST
            value: "my-release-postgresql.default"
          - name: POSTGRESQL_CLIENT_DATABASE_PORT_NUMBER
            value: "5432"
          - name: POSTGRESQL_CLIENT_POSTGRES_USER
            value: "postgres"
          - name: POSTGRESQL_CLIENT_POSTGRES_PASSWORD
            value: "xxx"

相关问题