mobject-server-daemon.c 1.37 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14
/*
 * (C) 2017 The University of Chicago
 * 
 * See COPYRIGHT in top-level directory.
 */

#include <mpi.h>
#include <margo.h>
#include <ssg.h>

#include "mobject-server.h"

void usage(void)
{
15
    fprintf(stderr, "Usage: mobject-server-daemon <listen_addr> <cluster_file>\n");
16
    fprintf(stderr, "  <listen_addr>    the Mercury address to listen on\n");
17
    fprintf(stderr, "  <cluster_file>   the file to write mobject cluster connect info to\n");
18 19 20 21 22 23
    exit(-1);
}

int main(int argc, char *argv[])
{
    char *listen_addr;
24
    char *cluster_file;
25 26 27 28 29 30 31
    margo_instance_id mid;
    int ret;

    /* check args */
    if (argc != 3)
        usage();
    listen_addr = argv[1];
32
    cluster_file = argv[2];
33 34 35 36 37 38 39 40 41 42 43

    /* XXX: MPI required for SSG bootstrapping */
    MPI_Init(&argc, &argv);

    mid = margo_init(listen_addr, MARGO_SERVER_MODE, 0, -1);
    if (mid == MARGO_INSTANCE_NULL)
    {
        fprintf(stderr, "Error: Unable to initialize margo\n");
        return -1;
    }

44
    ret = mobject_server_init(mid, cluster_file);
45 46 47 48 49 50 51 52
    if (ret != 0)
    {
        fprintf(stderr, "Error: Unable to initialize mobject server\n");
        margo_finalize(mid);
        return -1;
    }

    /* shutdown */
53
    margo_wait_for_finalize(mid); /* XXX: probably need a conditional here, so we can cleanup after blocking */
54
    mobject_server_shutdown(mid);
55
    //margo_finalize(mid);
56 57 58 59
    MPI_Finalize();

    return 0;
}