mobject-server-daemon.c 1.38 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
    margo_instance_id mid;
    int ret;
Matthieu Dorier's avatar
Matthieu Dorier committed
27
    mobject_server_context_t* mobject_svr_ctx;
28 29 30 31 32

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

    /* 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;
    }

Matthieu Dorier's avatar
Matthieu Dorier committed
45 46
    mobject_svr_ctx = mobject_server_init(mid, cluster_file);
    if (mobject_svr_ctx == NULL)
47 48 49 50 51 52
    {
        fprintf(stderr, "Error: Unable to initialize mobject server\n");
        margo_finalize(mid);
        return -1;
    }

53
    /* wait for shutdown signal, then clean up */
Matthieu Dorier's avatar
Matthieu Dorier committed
54
    mobject_server_wait_for_shutdown(mobject_svr_ctx);
55
    margo_finalize(mid);
56 57 58 59
    MPI_Finalize();

    return 0;
}