Verified Commit b4354828 authored by Alberto Miranda's avatar Alberto Miranda ♨️
Browse files

scord-ctl: Add support for configuration file

parent 886463d6
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -25,7 +25,7 @@
configure_file(scord.conf.in scord.conf)

# install the configuration file to sysconfdir (normally /etc)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/scord.conf
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/scord.conf scord-ctl.conf
        DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}
)

etc/scord-ctl.conf

0 → 100644
+45 −0
Original line number Diff line number Diff line
## vim: set filetype=yaml:

# Configuration of the `scord-ctl` service
config:
  # Specific configurations for supported adhoc storage systems
  adhoc_storage:
    gekkofs:
      # The default working directory for adhoc instances of this type
      working_directory: /tmp/gekkofs
      startup:
        # Specific environment variables that should be set for the adhoc
        # instance. These will be merged with the environment variables
        # already set by Slurm.
        environment:
          VAR0: value0
          VAR1: value1
        # The command that scord-ctl will use to start an adhoc instance of
        # this type. The following variables are supported that will be
        # automatically replaced by scord-ctl if found between curly braces:
        #  * ADHOC_NODES: A comma separated list of valid job hostnames that
        #    can be used to start the adhoc instance.
        #  * ADHOC_DIRECTORY: A unique working directory for each specific
        #    adhoc instance. This directory will be created by scord-ctl under
        #    `working_directory` and automatically removed after the adhoc
        #    instance has been shut down.
        #  * ADHOC_ID: - A unique ID for the adhoc instance.
        command: script.sh start
                    --hosts {ADHOC_NODES}
                    --workdir {ADHOC_DIRECTORY}
                    --datadir {ADHOC_DIRECTORY}/data
                    --mountdir {ADHOC_DIRECTORY}/mnt
      shutdown:
        environment:
        command: script.sh stop --workdir {ADHOC_DIRECTORY}


# default storage tiers made available to applications
storage:
  lustre:
    type: "pfs"
    mountpoint: "/mnt/lustre"

  tmp:
    type: "tmpfs"
    mountpoint: "/tmp"
+2 −2
Original line number Diff line number Diff line
@@ -263,7 +263,7 @@ server::install_signal_handlers() {
}

void
server::check_configuration() {}
server::check_configuration() const {}

void
server::print_greeting() {
@@ -276,7 +276,7 @@ server::print_greeting() {
}

void
server::print_configuration() {
server::print_configuration() const {
    LOGGER_INFO("");
    LOGGER_INFO("[[ Configuration ]]");
    LOGGER_INFO("  - running as daemon?: {}", m_daemonize ? "yes" : "no");
+7 −6
Original line number Diff line number Diff line
@@ -83,21 +83,22 @@ private:
    daemonize();
    void
    signal_handler(int);

    void
    init_logger();
    void
    install_signal_handlers();

    void
    check_configuration();
    void
    print_greeting();
    void
    print_configuration();
    void
    print_farewell();

protected:
    virtual void
    check_configuration() const;

    virtual void
    print_configuration() const;

private:
    std::string m_name;
    std::string m_address;
+29 −8
Original line number Diff line number Diff line
@@ -681,9 +681,26 @@ struct fmt::formatter<scord::node> : formatter<std::string_view> {
};

template <>
struct fmt::formatter<enum scord::adhoc_storage::type>
    : formatter<std::string_view> {
    // parse is inherited from formatter<string_view>.
struct fmt::formatter<enum scord::adhoc_storage::type> {

    // Presentation format: 'f' - full, 'e' - enum
    char m_presentation = 'f';

    constexpr auto
    parse(format_parse_context& ctx) -> decltype(ctx.begin()) {

        auto it = ctx.begin(), end = ctx.end();
        if(it != end && (*it == 'f' || *it == 'e')) {
            m_presentation = *it++;
        }

        if(it != end && *it != '}') {
            ctx.on_error("invalid format");
        }

        return it;
    }

    template <typename FormatContext>
    auto
    format(const enum scord::adhoc_storage::type& t, FormatContext& ctx) const {
@@ -693,20 +710,24 @@ struct fmt::formatter<enum scord::adhoc_storage::type>

        switch(t) {
            case adhoc_storage::type::gekkofs:
                name = "ADM_ADHOC_STORAGE_GEKKOFS";
                name = m_presentation == 'f' ? "ADM_ADHOC_STORAGE_GEKKOFS"
                                             : "gekkofs";
                break;
            case adhoc_storage::type::dataclay:
                name = "ADM_ADHOC_STORAGE_DATACLAY";
                name = m_presentation == 'f' ? "ADM_ADHOC_STORAGE_DATACLAY"
                                             : "dataclay";
                break;
            case adhoc_storage::type::expand:
                name = "ADM_ADHOC_STORAGE_EXPAND";
                name = m_presentation == 'f' ? "ADM_ADHOC_STORAGE_EXPAND"
                                             : "expand";
                break;
            case adhoc_storage::type::hercules:
                name = "ADM_ADHOC_STORAGE_HERCULES";
                name = m_presentation == 'f' ? "ADM_ADHOC_STORAGE_HERCULES"
                                             : "hercules";
                break;
        }

        return formatter<std::string_view>::format(name, ctx);
        return format_to(ctx.out(), "{}", name);
    }
};

Loading