Unverified Commit 008fd60f authored by Tommaso Tocci's avatar Tommaso Tocci
Browse files

Allow runtime configuration of daemon bind address

A new cli parameter `--listen`,`-l` allow to specify binding address/interface
parent 2648501c
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ private:
    uint64_t host_id_; // my host number
    size_t host_size_;
    unsigned int rpc_port_;
    std::string rpc_addr_;
    std::string lookup_file_;

    // Database
@@ -133,6 +134,10 @@ public:

    void rpc_port(unsigned int rpc_port);

    const std::string& rpc_addr() const;

    void rpc_addr(const std::string& addr);
    
    const std::string& lookup_file() const;

    void lookup_file(const std::string& lookup_file);
+7 −1
Original line number Diff line number Diff line
@@ -164,7 +164,7 @@ bool init_io_tasklet_pool() {
}

bool init_rpc_server() {
    auto protocol_port = fmt::format("{}://{}:{}", RPC_PROTOCOL, get_my_hostname(false), ADAFS_DATA->rpc_port());
    auto protocol_port = fmt::format("{}://{}:{}", RPC_PROTOCOL, ADAFS_DATA->rpc_addr(), ADAFS_DATA->rpc_port());
    hg_addr_t addr_self;
    hg_size_t addr_self_cstring_sz = 128;
    char addr_self_cstring[128];
@@ -337,6 +337,7 @@ int main(int argc, const char* argv[]) {
            ("mountdir,m", po::value<string>()->required(), "User Fuse mountdir")
            ("rootdir,r", po::value<string>()->required(), "ADA-FS data directory")
            ("metadir,i", po::value<string>(), "ADA-FS metadata directory, if not set rootdir is used for metadata ")
            ("listen,l", po::value<string>(), "Address or interface to bind the daemon on. Default: local hostname")
            ("port,p", po::value<unsigned int>()->default_value(DEFAULT_RPC_PORT), "Port to bind the server on. Default: 4433")
            ("hostfile", po::value<string>(), "Path to the hosts_file for all fs participants")
            ("hosts,h", po::value<string>(), "Comma separated list of hosts_ for all fs participants")
@@ -356,6 +357,11 @@ int main(int argc, const char* argv[]) {
        return 1;
    }

    if (vm.count("listen")) {
        ADAFS_DATA->rpc_addr(vm["listen"].as<string>());
    } else {
        ADAFS_DATA->rpc_addr(get_my_hostname(true) + HOSTNAME_SUFFIX);
    }
    ADAFS_DATA->rpc_port(vm["port"].as<unsigned int>());

    // parse host parameters
+8 −0
Original line number Diff line number Diff line
@@ -134,6 +134,14 @@ void FsData::rpc_port(unsigned int rpc_port) {
    FsData::rpc_port_ = rpc_port;
}

const std::string& FsData::rpc_addr() const {
    return rpc_addr_;
}

void FsData::rpc_addr(const std::string& addr) {
    rpc_addr_ = addr;
}

const std::string& FsData::lookup_file() const {
    return lookup_file_;
}