You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

20 regels
457 B

  1. #!/usr/bin/env python
  2. import socket
  3. import time
  4. import os
  5. host = os.environ.get('DATABASE_HOST', 'db')
  6. port = int(os.environ.get('DATABASE_PORT', '5432'))
  7. s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  8. timeout = 15
  9. while timeout != 0:
  10. try:
  11. s.connect((host, port))
  12. s.close()
  13. break
  14. except socket.error as ex:
  15. timeout -= 1
  16. print('wait for db to start... (%s sec remaining)' % timeout)
  17. time.sleep(1)