00_close_site 595 B

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