hepnos-daemon.cpp 1.14 KB
Newer Older
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 42 43 44 45 46 47 48 49 50 51 52
/*
 * (C) 2018 The University of Chicago
 * 
 * See COPYRIGHT in top-level directory.
 */
#include <string>
#include <iostream>
#include <fstream>
#include <vector>
#include <unistd.h>
#include <mpi.h>
#include <margo.h>
#include <bake-server.h>
#include <sdskv-server.h>
#include <yaml-cpp/yaml.h>
#include "hepnos-service.h"

#define ASSERT(__cond, __msg, ...) { if(!(__cond)) { fprintf(stderr, "[%s:%d] " __msg, __FILE__, __LINE__, __VA_ARGS__); exit(-1); } }

void usage(void)
{
    fprintf(stderr, "Usage: hepnos-service <addr> <config>\n");
    fprintf(stderr, "  <addr>    the Mercury address to listen on (e.g. tcp://)\n");
    fprintf(stderr, "  <config>  path to the YAML file to generate for clients\n");
    exit(-1);
}

int main(int argc, char *argv[])
{
    char* listen_addr;
    char* config_file;
    int rank;

    MPI_Init(&argc, &argv);
    MPI_Comm_rank(MPI_COMM_WORLD, &rank);

    if(argc != 3) {
        if(rank == 0) {
            usage();
        }
        MPI_Finalize();
        exit(0);
    }

    listen_addr = argv[1];
    config_file = argv[2];

    hepnos_run_service(MPI_COMM_WORLD, listen_addr, config_file);

    MPI_Finalize();
}