Go to the documentation of this file.00001
00008
00009
00010
00011 #include "utility.h"
00012
00013 #include <stdlib.h>
00014 #include <string.h>
00015
00016 #include "comm_data.h"
00017 #include "comm_basics.h"
00018 #include "comm_encode.h"
00019 #include "general.h"
00020 #include "gs_tools.h"
00021
00031 int
00032 main(int argc, char **argv)
00033 {
00034 char dottedIP[20], proxy_dottedIP[20], cid_string[2 * CID_LEN + 1];
00035 char server_name[2 * CID_LEN + 3];
00036 int i, num_failed, sock, num_servers, agentport;
00037 gs_server_t **server_list;
00038
00039 if(argc < 2) {
00040 fprintf(stderr,"Usage: GS_kill_all <agent name>\n");
00041 exit(EXIT_FAILURE);
00042 }
00043
00044 initialize_sockets();
00045
00046 agentport = getenv_int("GRIDSOLVE_AGENT_PORT", GRIDSOLVE_AGENT_PORT_DEFAULT);
00047 if((sock = gs_connect_direct(argv[1], agentport)) == INVALID_SOCKET) {
00048 fprintf(stderr,"%s cannot be contacted\n", argv[1]);
00049 exit(EXIT_FAILURE);
00050 }
00051
00052 server_list = gs_tools_get_all_servers(argv[1], agentport, &num_servers);
00053
00054 num_failed = 0;
00055
00056 for(i=0;i<num_servers;i++) {
00057 proxy_cid_to_str(cid_string, server_list[i]->componentid);
00058 proxy_ip_to_str(server_list[i]->ipaddress, dottedIP);
00059 proxy_ip_to_str(server_list[i]->proxyip, proxy_dottedIP);
00060 if(server_list[i]->proxyip != 0)
00061 printf("killing server %s (%s:%d, proxy=%s:%d) [cid=%s]\n", server_list[i]->hostname,
00062 dottedIP, server_list[i]->port, proxy_dottedIP,
00063 server_list[i]->proxyport, cid_string);
00064 else
00065 printf("killing server %s (%s:%d) [cid=%s]\n", server_list[i]->hostname,
00066 dottedIP, server_list[i]->port, cid_string);
00067
00068 sprintf(server_name, "-c%s", cid_string);
00069
00070 if(gs_kill_server(argv[1], agentport, server_name) < 0) {
00071 fprintf(stderr, "Failed to kill server %s (%s)\n", server_list[i]->hostname, cid_string);
00072 num_failed++;
00073 }
00074 }
00075
00076 if(gs_kill_agent(argv[1], agentport) < 0)
00077 fprintf(stderr, "Failed to kill agent %s\n", argv[1]);
00078
00079 cleanup_sockets();
00080
00081 return 0;
00082 }