2020-05-02 16:23:56 +12:00
|
|
|
const Service = require('../service.js');
|
|
|
|
|
|
|
|
class Health extends Service {
|
|
|
|
|
|
|
|
/**
|
2020-05-17 17:29:57 +12:00
|
|
|
* Get HTTP
|
2020-05-02 16:23:56 +12:00
|
|
|
*
|
|
|
|
* Check the Appwrite HTTP server is up and responsive.
|
|
|
|
*
|
|
|
|
* @throws Exception
|
|
|
|
* @return {}
|
|
|
|
*/
|
|
|
|
async get() {
|
|
|
|
let path = '/health';
|
|
|
|
|
|
|
|
return await this.client.call('get', path, {
|
|
|
|
'content-type': 'application/json',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-05-17 17:29:57 +12:00
|
|
|
* Get Anti virus
|
|
|
|
*
|
|
|
|
* Check the Appwrite Anti Virus server is up and connection is successful.
|
|
|
|
*
|
|
|
|
* @throws Exception
|
|
|
|
* @return {}
|
|
|
|
*/
|
|
|
|
async getAntiVirus() {
|
|
|
|
let path = '/health/anti-virus';
|
|
|
|
|
|
|
|
return await this.client.call('get', path, {
|
|
|
|
'content-type': 'application/json',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get Cache
|
2020-05-02 16:23:56 +12:00
|
|
|
*
|
|
|
|
* Check the Appwrite in-memory cache server is up and connection is
|
|
|
|
* successful.
|
|
|
|
*
|
|
|
|
* @throws Exception
|
|
|
|
* @return {}
|
|
|
|
*/
|
|
|
|
async getCache() {
|
|
|
|
let path = '/health/cache';
|
|
|
|
|
|
|
|
return await this.client.call('get', path, {
|
|
|
|
'content-type': 'application/json',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-05-17 17:29:57 +12:00
|
|
|
* Get DB
|
2020-05-02 16:23:56 +12:00
|
|
|
*
|
|
|
|
* Check the Appwrite database server is up and connection is successful.
|
|
|
|
*
|
|
|
|
* @throws Exception
|
|
|
|
* @return {}
|
|
|
|
*/
|
|
|
|
async getDB() {
|
|
|
|
let path = '/health/db';
|
|
|
|
|
|
|
|
return await this.client.call('get', path, {
|
|
|
|
'content-type': 'application/json',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-05-17 17:29:57 +12:00
|
|
|
* Get Certificate Queue
|
2020-05-02 16:23:56 +12:00
|
|
|
*
|
|
|
|
* Get the number of certificates that are waiting to be issued against
|
|
|
|
* [Letsencrypt](https://letsencrypt.org/) in the Appwrite internal queue
|
|
|
|
* server.
|
|
|
|
*
|
|
|
|
* @throws Exception
|
|
|
|
* @return {}
|
|
|
|
*/
|
|
|
|
async getQueueCertificates() {
|
|
|
|
let path = '/health/queue/certificates';
|
|
|
|
|
|
|
|
return await this.client.call('get', path, {
|
|
|
|
'content-type': 'application/json',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-05-17 17:29:57 +12:00
|
|
|
* Get Functions Queue
|
|
|
|
*
|
|
|
|
* @throws Exception
|
|
|
|
* @return {}
|
|
|
|
*/
|
|
|
|
async getQueueFunctions() {
|
|
|
|
let path = '/health/queue/functions';
|
|
|
|
|
|
|
|
return await this.client.call('get', path, {
|
|
|
|
'content-type': 'application/json',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get Logs Queue
|
2020-05-02 16:23:56 +12:00
|
|
|
*
|
|
|
|
* Get the number of logs that are waiting to be processed in the Appwrite
|
|
|
|
* internal queue server.
|
|
|
|
*
|
|
|
|
* @throws Exception
|
|
|
|
* @return {}
|
|
|
|
*/
|
|
|
|
async getQueueLogs() {
|
|
|
|
let path = '/health/queue/logs';
|
|
|
|
|
|
|
|
return await this.client.call('get', path, {
|
|
|
|
'content-type': 'application/json',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-05-17 17:29:57 +12:00
|
|
|
* Get Tasks Queue
|
2020-05-02 16:23:56 +12:00
|
|
|
*
|
|
|
|
* Get the number of tasks that are waiting to be processed in the Appwrite
|
|
|
|
* internal queue server.
|
|
|
|
*
|
|
|
|
* @throws Exception
|
|
|
|
* @return {}
|
|
|
|
*/
|
|
|
|
async getQueueTasks() {
|
|
|
|
let path = '/health/queue/tasks';
|
|
|
|
|
|
|
|
return await this.client.call('get', path, {
|
|
|
|
'content-type': 'application/json',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-05-17 17:29:57 +12:00
|
|
|
* Get Usage Queue
|
2020-05-02 16:23:56 +12:00
|
|
|
*
|
|
|
|
* Get the number of usage stats that are waiting to be processed in the
|
|
|
|
* Appwrite internal queue server.
|
|
|
|
*
|
|
|
|
* @throws Exception
|
|
|
|
* @return {}
|
|
|
|
*/
|
|
|
|
async getQueueUsage() {
|
|
|
|
let path = '/health/queue/usage';
|
|
|
|
|
|
|
|
return await this.client.call('get', path, {
|
|
|
|
'content-type': 'application/json',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-05-17 17:29:57 +12:00
|
|
|
* Get Webhooks Queue
|
2020-05-02 16:23:56 +12:00
|
|
|
*
|
|
|
|
* Get the number of webhooks that are waiting to be processed in the Appwrite
|
|
|
|
* internal queue server.
|
|
|
|
*
|
|
|
|
* @throws Exception
|
|
|
|
* @return {}
|
|
|
|
*/
|
|
|
|
async getQueueWebhooks() {
|
|
|
|
let path = '/health/queue/webhooks';
|
|
|
|
|
|
|
|
return await this.client.call('get', path, {
|
|
|
|
'content-type': 'application/json',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-05-17 17:29:57 +12:00
|
|
|
* Get Local Storage
|
2020-05-02 16:23:56 +12:00
|
|
|
*
|
|
|
|
* Check the Appwrite local storage device is up and connection is successful.
|
|
|
|
*
|
|
|
|
* @throws Exception
|
|
|
|
* @return {}
|
|
|
|
*/
|
|
|
|
async getStorageLocal() {
|
|
|
|
let path = '/health/storage/local';
|
|
|
|
|
|
|
|
return await this.client.call('get', path, {
|
|
|
|
'content-type': 'application/json',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-05-17 17:29:57 +12:00
|
|
|
* Get Time
|
2020-05-02 16:23:56 +12:00
|
|
|
*
|
|
|
|
* Check the Appwrite server time is synced with Google remote NTP server. We
|
|
|
|
* use this technology to smoothly handle leap seconds with no disruptive
|
|
|
|
* events. The [Network Time
|
|
|
|
* Protocol](https://en.wikipedia.org/wiki/Network_Time_Protocol) (NTP) is
|
|
|
|
* used by hundreds of millions of computers and devices to synchronize their
|
|
|
|
* clocks over the Internet. If your computer sets its own clock, it likely
|
|
|
|
* uses NTP.
|
|
|
|
*
|
|
|
|
* @throws Exception
|
|
|
|
* @return {}
|
|
|
|
*/
|
|
|
|
async getTime() {
|
|
|
|
let path = '/health/time';
|
|
|
|
|
|
|
|
return await this.client.call('get', path, {
|
|
|
|
'content-type': 'application/json',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = Health;
|