Skip to content

Commit

Permalink
fix: test pg script
Browse files Browse the repository at this point in the history
  • Loading branch information
Julien Bouquillon committed Jul 28, 2020
1 parent 1eb71d1 commit 731630e
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/utils/waitForPostgres.ts
Expand Up @@ -6,12 +6,20 @@ interface WaitForPostgresParams {
secretRefName: string;
}

const script = `
retry=120; # 5s * (12 * 10) = 10min
while ! pg_isready -d \${DATABASE_URL} > /dev/null 2> /dev/null && [[ $(( retry-- )) -gt 0 ]];
do
echo "Waiting for Postgres to go Green ($(( retry )))" ; sleep 5s ; done ;
echo Ready;
`;

export const waitForPostgres = ({
secretRefName = "azure-pg-user",
}: WaitForPostgresParams): IIoK8sApiCoreV1Container => {
return {
name: "wait-for-postgres",
image: `registry.gitlab.factory.social.gouv.fr/socialgouv/docker/wait-for-postgres:1.50.0`,
image: `postgres:10`,
imagePullPolicy: "Always",
resources: {
requests: {
Expand All @@ -30,5 +38,6 @@ export const waitForPostgres = ({
},
},
],
command: ["sh", "-c", script],
};
};

0 comments on commit 731630e

Please sign in to comment.