Guest User

Untitled

a guest
Jan 22nd, 2018
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. #!/bin/bash
  2. # wait-for-postgres.sh
  3.  
  4. set -e
  5.  
  6. host="$1"
  7. shift
  8. cmd="$@"
  9.  
  10. until psql -h "$host" -U "postgres" -c 'l'; do
  11. >&2 echo "Postgres is unavailable - sleeping"
  12. sleep 1
  13. done
  14.  
  15. >&2 echo "Postgres is up - executing command"
  16. exec $cmd
  17.  
  18. version: '2'
  19. services:
  20. server:
  21. build: .
  22. ports:
  23. - 3030:3030
  24. depends_on:
  25. - database
  26. command: ["./setup/wait-for-postgres.sh", "localhost:5432", "--", "node", "src"]
  27. database:
  28. image: postgres
  29. environment:
  30. - "POSTGRES_USER=postgres"
  31. - "POSTGRES_PASSWORD=postgres"
  32. - "POSTGRES_DB=tide_server"
  33. ports:
  34. - 5432:5432
  35.  
  36. server_1 | Postgres is unavailable - sleeping
  37. server_1 | psql: could not translate host name "192.168.64.2:5432" to address: Name or servi
  38. ce not known
  39. server_1 | Postgres is unavailable - sleeping
  40. server_1 | psql: could not translate host name "192.168.64.2:5432" to address: Name or servi
  41. ce not known
  42. server_1 | Postgres is unavailable - sleeping
  43. server_1 | psql: could not translate host name "192.168.64.2:5432" to address: Name or servi
  44. ce not known
  45.  
  46. version: '2'
  47. services:
  48. server:
  49. build: .
  50. ports:
  51. - 3030:3030
  52. links:
  53. - database
  54. #environment could be usefull too
  55. environment:
  56. DATABASE_HOST: database
  57. command: ["./setup/wait-for-postgres.sh", "localhost:5432", "--", "node", "src"]
  58. database:
  59. image: postgres
  60. environment:
  61. - "POSTGRES_USER=postgres"
  62. - "POSTGRES_PASSWORD=postgres"
  63. - "POSTGRES_DB=tide_server"
  64. ports:
  65. - 5432:5432
Add Comment
Please, Sign In to add comment