summaryrefslogtreecommitdiffstats
path: root/config/src/vespa/config/common/configsystem.cpp
blob: b7d1f32b1438000db09c018f201bb638749d9e6f (plain) (blame)
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
33
34
35
36
37
38
39
40
41
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#include "configsystem.h"
#include <vespa/defaults.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>

namespace config {

namespace {

vespalib::string getConfigProxyFileName() {
    vespalib::string root(vespa::Defaults::vespaHome());
    return root + "var/run/configproxy.pid";
}

}

ConfigSystem::ConfigSystem() :
    _configProxyPidFile(getConfigProxyFileName())
{
}

bool ConfigSystem::isUp() const {
    return isConfigProxyRunning();
}

bool ConfigSystem::isConfigProxyRunning() const {
    struct stat fs;

    int retval = stat(_configProxyPidFile.c_str(), &fs);
    if (retval == 0) {
        if (S_ISREG(fs.st_mode)) {
            return true;
        }
    }
    return false;
}

}