00_close_site 649 B

1234567891011121314151617181920212223242526
  1. #!/bin/sh
  2. . /etc/container_environment.sh
  3. . /etc/overleaf/env.sh
  4. SITE_MAINTENANCE_FILE_BAK="$SITE_MAINTENANCE_FILE.bak.shutdown"
  5. mv "${SITE_MAINTENANCE_FILE}" "${SITE_MAINTENANCE_FILE_BAK}"
  6. echo "closed" > "${SITE_MAINTENANCE_FILE}"
  7. # status file is polled every 5 seconds
  8. sleep 5
  9. # giving a grace period of 5 seconds for users before disconnecting them and start shutting down
  10. cd /overleaf/services/web && node scripts/disconnect_all_users.js 5 >> /var/log/overleaf/web.log 2>&1
  11. EXIT_CODE="$?"
  12. if [ $EXIT_CODE -ne 0 ]
  13. then
  14. echo "scripts/disconnect_all_users.js failed with exit code $EXIT_CODE"
  15. fi
  16. # wait for disconnection
  17. sleep 5
  18. exit 0