bb-shutdown.c 1.11 KB
Newer Older
Philip Carns's avatar
Philip Carns committed
1
2
3
4
5
6
7
8
9
10
/*
 * (C) 2015 The University of Chicago
 * 
 * See COPYRIGHT in top-level directory.
 */

#include <stdio.h>
#include <assert.h>
#include <unistd.h>

Philip Carns's avatar
Philip Carns committed
11
12
13
#include "abt.h"
#include "abt-snoozer.h"
#include "bake-bulk.h"
Philip Carns's avatar
Philip Carns committed
14
15
16
17
18
19

/* client program that will shut down a BAKE bulk server. */

int main(int argc, char **argv) 
{
    int ret;
Philip Carns's avatar
Philip Carns committed
20
    bake_target_id_t bti;
Philip Carns's avatar
Philip Carns committed
21
22
23
24
25
26
27
28
 
    if(argc != 2)
    {
        fprintf(stderr, "Usage: bb-shutdown <server addr to stop>\n");
        fprintf(stderr, "  Example: ./bb-shutdown tcp://localhost:1234\n");
        return(-1);
    }       

Philip Carns's avatar
Philip Carns committed
29
    /* set up Argobots */
Philip Carns's avatar
Philip Carns committed
30
31
32
33
34
35
36
37
38
39
40
41
42
    ret = ABT_init(argc, argv);
    if(ret != 0)
    {
        fprintf(stderr, "Error: ABT_init()\n");
        return(-1);
    }
    ret = ABT_snoozer_xstream_self_set();
    if(ret != 0)
    {
        fprintf(stderr, "Error: ABT_snoozer_xstream_self_set()\n");
        return(-1);
    }

Philip Carns's avatar
Philip Carns committed
43
44
    ret = bake_probe_instance(argv[1], &bti);
    if(ret < 0)
Philip Carns's avatar
Philip Carns committed
45
    {
Philip Carns's avatar
Philip Carns committed
46
        fprintf(stderr, "Error: bake_probe_instance()\n");
Philip Carns's avatar
Philip Carns committed
47
48
49
        return(-1);
    }

Philip Carns's avatar
Philip Carns committed
50
51
    /* shutdown server */
    bake_shutdown_service(bti);
Philip Carns's avatar
Philip Carns committed
52

Philip Carns's avatar
Philip Carns committed
53
    bake_release_instance(bti);
Philip Carns's avatar
Philip Carns committed
54
55
56
57

    return(0);
}