healthcheck.sh 662 B

12345678910111213141516171819202122
  1. {% macro healthcheck(values) -%}
  2. #!/bin/sh
  3. {% set base_path = "/var/syncthing/config" %}
  4. {# If the db is migrated, use the normal healthcheck #}
  5. if [ -d "{{base_path}}/index-v2" ]; then
  6. wget --quiet --spider http://127.0.0.1:{{values.network.web_port.port_number}}/rest/noauth/health || exit 1
  7. exit 0
  8. fi
  9. {#
  10. Let syncthing migrate the db, in the meantime, report healthy,
  11. so docker compose up command does not timeout.
  12. #}
  13. if [ -d "{{base_path}}/index-v0.14.0.db" ]; then
  14. echo "Migrating database, reporting healthy"
  15. exit 0
  16. fi
  17. {# Something went wrong, report unhealthy #}
  18. echo "Something went wrong, reporting unhealthy"
  19. exit 1
  20. {% endmacro %}