maintenance.js 761 B

1234567891011121314151617181920212223242526272829303132
  1. /**
  2. * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
  3. * SPDX-License-Identifier: AGPL-3.0-or-later
  4. */
  5. import Axios from '@nextcloud/axios'
  6. import { getRootUrl } from '@nextcloud/router'
  7. const url = getRootUrl() + '/status.php'
  8. const check = () => {
  9. console.info('checking the Nextcloud maintenance status')
  10. Axios.get(url)
  11. .then(resp => resp.data)
  12. .then(status => {
  13. if (status.maintenance === false) {
  14. console.info('Nextcloud is not in maintenance mode anymore -> reloading')
  15. window.location.reload()
  16. return
  17. }
  18. console.info('Nextcloud is still in maintenance mode')
  19. // Wait 20sec before the next request
  20. setTimeout(check, 20 * 1000)
  21. })
  22. .catch(console.error.bind(this))
  23. }
  24. // Off we go!
  25. check()