aboutsummaryrefslogtreecommitdiffstats
path: root/core/src/maintenance.js
blob: e66b14a88f558a640254acb905aa5a49f929d32a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/**
 * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
 * SPDX-License-Identifier: AGPL-3.0-or-later
 */

import Axios from '@nextcloud/axios'
import { getRootUrl } from '@nextcloud/router'

const url = getRootUrl() + '/status.php'

const check = () => {
	console.info('checking the Nextcloud maintenance status')
	Axios.get(url)
		.then(resp => resp.data)
		.then(status => {
			if (status.maintenance === false) {
				console.info('Nextcloud is not in maintenance mode anymore -> reloading')

				window.location.reload()
				return
			}

			console.info('Nextcloud is still in maintenance mode')

			// Wait 20sec before the next request
			setTimeout(check, 20 * 1000)
		})
		.catch(console.error.bind(this))
}

// Off we go!
check()