aboutsummaryrefslogtreecommitdiff
path: root/src/server/ApiManagers/DiagnosticManager.ts
blob: 10498548118bd5d4bd98b668a35d7fd35a3c64c1 (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
import ApiManager, { Registration } from "./ApiManager";
import { Method } from "../RouteManager";
import request = require('request-promise');

export default class DiagnosticManager extends ApiManager {

    protected initialize(register: Registration): void {

        register({
            method: Method.GET,
            subscription: "/serverHeartbeat",
            onValidation: ({ res }) => res.send(true)
        });

        register({
            method: Method.GET,
            subscription: "/solrHeartbeat",
            onValidation: async ({ res }) => {
                try {
                    await request("http://localhost:8983");
                    res.send({ running: true });
                } catch (e) {
                    res.send({ running: false });
                }
            }
        });

    }

}